开发者

What is the use of the Style tag between Button.Style and Style.Trigger?

开发者 https://www.devze.com 2023-02-16 00:47 出处:网络
What is the use of the Style tag between Button.Style and Style.Trigger? Is it because Style an attached property?

What is the use of the Style tag between Button.Style and Style.Trigger? Is it because Style an attached property?

<Button.Style>                
    <Style >
        <Style.Triggers>
            <Trigger Property="Button.IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation From="1" To="15" Storyboard.TargetProperty="FontSize"></DoubleAnimation>
                        </Storyboard>
    开发者_Go百科                </BeginStoryboard>
                </Trigger.EnterActions>
            </Trigger>
        </Style.Triggers>
    </Style>
</Button.Style>


This is what the XAML what look like in code:

var button = new Button();
button.Style = new Style();
button.Style.Triggers.Add(new Trigger() ...);

The tag <Button.Style> references a property on Button and with the <Style> tag you are setting the style property to an object of type Style. If you had a derived class for Style, such as MyStyle, then the XAML would look like this:

<Button.Style>                
    <local:MyStyle>
    </local:MyStyle>
</Button.Style>
0

精彩评论

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