Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to change Style at runtime in application-level

 
 
Old 02-09-2006   #1 (permalink)
HolaMan


 
 

How to change Style at runtime in application-level

Hi~

I want to change the style of all controls in application which
contains pages.
In document, I can use Style in Application.Resource

<Application.Resources>
<Style TargetType="{x:Type Button}"> ... </Style>
</Application.Resources>

But I can't change this style at runtime.
I try to use Application.Current.FindResource to get this style
reference and modify Setters, but get an InvalidOperationException, it
says the style is sealed(in use) and I can't modify it.
and I try to use BaseOn property to dynamically binding other style but
still get an exception.

Is there easier way to change a specified control's style in
application-level?
or release the sealed status of the style?

Thanks :-)


My System SpecsSystem Spec
Old 02-09-2006   #2 (permalink)
HolaMan


 
 

Re: How to change Style at runtime in application-level


I have the book "Programming Windows Presentation Foundation" O'Reilly
There's a solution for replace skin at runtime in Chapter 6.
It dynamically replace the Application.Current.Resources, and it works.

But I still have no idea how can I modify the style which in use.
Thanks :-)

My System SpecsSystem Spec
Old 02-11-2006   #3 (permalink)
Michael Latta


 
 

Re: How to change Style at runtime in application-level

I would not think you can just modify the style object and have the system
do the right thing. It might work, but I would be surprised they chose to
have that level of overhead listening for changes on style objects. What is
likely to work is to derive a new style object from the old one, then assign
the new style to the visuals you wish affected. If you want to restyle
elements with updated default styles that may take some experimentation. I
would think that once a style is applied to an element, that changes to the
style object are not reapplied to the element. However when you set the
style property to a new style it would update the element.

Michael


"HolaMan" <reality.chang@gmail.com> wrote in message
news:1139477354.044628.33090@o13g2000cwo.googlegroups.com...
>
> I have the book "Programming Windows Presentation Foundation" O'Reilly
> There's a solution for replace skin at runtime in Chapter 6.
> It dynamically replace the Application.Current.Resources, and it works.
>
> But I still have no idea how can I modify the style which in use.
> Thanks :-)
>



My System SpecsSystem Spec
Old 02-14-2006   #4 (permalink)
HolaMan


 
 

Re: How to change Style at runtime in application-level

Dear Michael, Thanks for you reply :-)

If I want to change a style of element, I can apply a new style for
that element.

However, if I want to change page-wise or application-wise style for
some controls, is there any quickly way to achieve?
or I need literally apply each element in a page or application.

Best Regards

My System SpecsSystem Spec
Old 02-14-2006   #5 (permalink)
HolaMan


 
 

Re: How to change Style at runtime in application-level

Thanks u Michael

I got your mean :-)
Thanks u very much

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
.Net 2 Web Application -> Multi-Level web form .NET General
How does one get the application name of a C# program at runtime .NET General
How Do I change the All Programs menu style? Vista General
application causing runtime error Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46