WPF: How do I set a UI Element's background property to null/nothing/default in XAML?
-
18-09-2019 - |
Question
Using code, I can set a UI element's background property to its default value by setting it to nothing
, i.e.
myControl.Background = Nothing
But how do I do this in XAML? In particular, I'm doing this in a Storyboard:
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
Duration="00:00:02.00"
To="DEFAULT_COLOR_HERE" />
</Storyboard>
Solution
Give this a shot
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"
Duration="00:00:02.00"
To="{x:Null}" />
</Storyboard>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow