![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | Re: How to change Style at runtime in application-level Thanks u Michael I got your mean :-) Thanks u very much |
My System Specs![]() |
| 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 | |||