tags:

views:

34

answers:

1

Let's say we define button style in .Resource tags. The style is apply to all button (TargetTye=Button, x:Key is not set). In some parts of my application, I want to turn this style off.

I seek for a solution where a "style undo" feature can happen. Like typing in MS Word, when you try some formation (bold/underline) - should read as applying a style - and later you undo it to return to initial state.

How can I do it? All helps are very much appreciated!

[Edit]

My question is similar to the one here How to invoke windows theme in WPF? - Stack Overflow where the invoked theme is the currently-selected theme of the Windows OS.

+3  A: 

just give like this

Style={x:Null}

<Button Style={x:Null} Content="Show"/>
Kishore Kumar
Thank you. It's a thought. But we cannot use this approach to turn off styles for forms whose codes mustn't be changed. Eg. we need clicking a button to switch the theme.
Nam Gi VU
to change the entire Applicatin theme?
Kishore Kumar
Yes, somehow like that, but I just make the problem "small", for button controls only.
Nam Gi VU
for that you have to create different resources file for each theme(in your case only for Button) and you have load that theme resource file dynamically at runtime (Application Resource). To implement that you have to use DynamicResource instead of StaticResource
Kishore Kumar
I understand your suggestion, Kishore. But still need to make myself clearer: I want a style "undo" feature. Like typing in MS Word, when you try some formation (bold/underline) - should read as applying a style - and later you undo it to return to initial state. I seek for the technique to undo the style applying. Your suggestion require the knowledge of the currently-used theme/style.
Nam Gi VU
There are two option for this. 1. Use Toggle button and create your own style and change the background color combination for Checked and Unchecked State (ex. if the toggle button is checked let it be red and if not black). 2. Create a custom button with some property to accept the background color or property to identify the state of the button. Based in on the property you create triggers to change the color .
Kishore Kumar