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>
精彩评论