10

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?

[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.

Community
  • 1
  • 1
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

1 Answers1

16

just give like this

Style={x:Null}

<Button Style="{x:Null}" Content="Show"/>
boop
  • 7,413
  • 13
  • 50
  • 94
Kishore Kumar
  • 21,449
  • 13
  • 81
  • 113
  • 1
    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 G VU Oct 13 '10 at 04:36
  • to change the entire Applicatin theme? – Kishore Kumar Oct 13 '10 at 04:43
  • Yes, somehow like that, but I just make the problem "small", for button controls only. – Nam G VU Oct 13 '10 at 04:45
  • 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 Oct 13 '10 at 06:07
  • 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 G VU Oct 13 '10 at 06:45
  • 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 Oct 13 '10 at 06:53