开发者

WPF: How do I set a UI Element's background property to null/nothing/default in XAML?

开发者 https://www.devze.com 2022-12-10 06:34 出处:网络
Using code, I can set a UI element\'s background property to its default value by setting it to nothing, i.e.

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开发者_JAVA百科, I'm doing this in a Storyboard:

<Storyboard>
    <ColorAnimation 
        Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" 
        Duration="00:00:02.00" 
        To="DEFAULT_COLOR_HERE" />
</Storyboard>


Give this a shot

<Storyboard>
    <ColorAnimation 
        Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" 
        Duration="00:00:02.00" 
        To="{x:Null}" />
</Storyboard>
0

精彩评论

暂无评论...
验证码 换一张
取 消