We’ve an application in which we have the default control styles defined as implicit style.
XAML:
<Style TargetType="Button">
[...]
</Style>
These styles are now applied to every button in the application.
Sometimes we change the style in code-behind to something different.
XAML:
<Style x:Key="HighlightStyle" TargetType="Button">
[...]
</Style>
Code:
cmdButton.Style = App.Current.Resources("HighlightStyle")
Then again we want to remove the style and return to the implicit style, but this doesn’t seem to be possible:
Code:
cmdButton.Style = Nothing
Results in an unstyled Button.
I’ve also read here http://www.silverlightshow.net/items/Implicit-Styles-in-Silverlight-4.aspx that all implicit style should be accessible by the TargetType-Value as Key, but this doesn’t seem to work either.
Does anyone know a way around this?
As usual, as soon as i’ve posted the question, i’ve come up with a solution:
Using the ClearValue Method on the Object clears the style property leaving it on the default style.