Silverlight 3 is introducing a small, but very powerful feature: styles in Silverlight 3 can be set multiple times! For example, executing the following code in Silverlight 2 will throw a “catastrophic failure” exception on the second line:
textBox.Style = Application.Current.Resources["TextBoxStyle"] as Style;
textBox.Style = Application.Current.Resources["TextBoxStyle"] as Style;
Silverlight 3, on the other hand, won’t have any problems with setting control’s style the second, third or n-th time, if required.
To reset a control’s style, one can simply set it to null:
textBox.Style = null;
… or assign an empty style to it:
<Style x:Key="EmptyTextBoxStyle" TargetType="TextBox" />
Source code below:
c3da3b5a-2dac-47ec-8151-154d177abdf6|0|.0|27604f05-86ad-47ef-9e05-950bb762570c
Tags :