I have a simple textBox in my project.
I made this style (for illustration purposes):
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Style.Setters>
<Setter Property="Background" Value="LightGray"/>
</Style.Setters>
</Style>
then at one point, I'm doing: MyTextBox.Background = Brushes.Red
in my code-behind.
up to there, everything works fine.
now I would like to be able to revert to the original background color, but without hardcoding it.
i.e.: I know I can do MyTextBox.Background = Brushes.LightGray
, but I'm looking for a generic way that would enable me to revert to the original style's background property, without knowing it.
I tried setting it to null, but of course it gives me a transparent background, which is not what I want.
is this possible at all? and if yes, how can I achieve this ?
thanks
MyTextBox.ClearValue(TextBox.BackgroundProperty);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With