标签:动画效果 anim cond focus 要求 animation targe mat 时间
<Window.Resources> <FontFamily x:Key="ButtonFontFamily">Times New Roman</FontFamily> <sys:Double x:Key="ButtonFontSize">18</sys:Double> <FontWeight x:Key="ButtonFontWeight">Bold</FontWeight> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <Button FontFamily="{StaticResource ButtonFontFamily}" FontSize="{StaticResource ButtonFontSize}" FontWeight="{StaticResource ButtonFontWeight}"> </Button> </Grid>
<Window.Resources> <Style x:Key="BigFontButtonStyle"> <Setter Property="Control.FontFamily" Value="Times New Roman"/> <Setter Property="Control.FontSize" Value="18"/> <Setter Property="Control.FontWeight" Value="Bold"/> </Style> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <Button Style="{StaticResource BigFontButtonStyle}"> </Button> </Grid>
<Setter Property="Control.Background"> <Setter.Value> <ImageBrush TileMode="Tile" ViewboxUnits="Absolute" Viewport="0 0 32 32" ImageSource="" Opacity="0.3"></ImageBrush> </Setter.Value> </Setter>
<Style x:Key="BigFontButtonStyle" TargetType="Button"> <Setter Property="FontFamily" Value="Times New Roman"/> <Setter Property="FontSize" Value="18"/> <Setter Property="FontWeight" Value="Bold"/> </Style>
<Window.Resources> <Style x:Key="MouseOverHighlightStyle"> <EventSetter Event="TextBlock.MouseEnter" Handler="element_MouseEnter"></EventSetter> <EventSetter Event="TextBlock.MouseLeave" Handler="element_MouseLeave"></EventSetter> </Style> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <TextBlock Style="{StaticResource MouseOverHighlightStyle}"></TextBlock> </Grid>
<Window.Resources> <Style x:Key="BigFontButtonStyle"> <Setter Property="Control.FontFamily" Value="Times New Roman"/> <Setter Property="Control.FontSize" Value="18"/> <Setter Property="Control.FontWeight" Value="Bold"/> </Style> <Style x:Key="NewBigButtonBigFontStyle" BasedOn="{StaticResource BigFontButtonStyle}"> <Setter Property="Control.Foreground" Value="Red"/> <Setter Property="Control.Background" Value="DarkBlue"/> </Style> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <TextBlock Style="{StaticResource NewBigButtonBigFontStyle}">test</TextBlock> </Grid>
<Window.Resources> <Style TargetType="Button"> <Setter Property="Control.FontFamily" Value="Times New Roman"/> <Setter Property="Control.FontSize" Value="18"/> <Setter Property="Control.FontWeight" Value="Bold"/> </Style> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <Button>one</Button> <Button Style="{x:Null}">two</Button> <Button>three</Button> </Grid>
名称 | 说明 |
Trigger | 这是一种最简单的触发器。可以监测依赖项属性的变化,然后设置器改变样式。 |
MultiTrigger | 与Trigger类似,但这种触发器联合了多个条件。只有满足了所有这些条件,才会启动触发器。 |
DataTrigger | 这种触发器使用数据绑定,与Trigger类似,只不过监视的是任意绑定数据的变化。 |
MultiDataTrigger | 联合多个数据触发器。 |
EventTrigger | 这是最复杂的触发器。当事件发生时,这种触发器应用动画。 |
<Window.Resources> <Style x:Key="BigFontButton"> <Style.Setters> <Setter Property="Control.FontFamily" Value="Times New Roman"/> <Setter Property="Control.FontSize" Value="18"/> <Setter Property="Control.FontWeight" Value="Bold"/> </Style.Setters> <Style.Triggers> <Trigger Property="Control.IsFocused" Value="True"> <Setter Property="Control.Foreground" Value="DarkRed"/> </Trigger> </Style.Triggers> </Style> </Window.Resources>
<Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Property="Control.IsFocused" Value="true"/> <Condition Property="Control.IsMouseOver" Value="true"/> </MultiDataTrigger.Conditions> <MultiDataTrigger.Setters> <Setter Property="Control.Foreground" Value="DarkRed"/> </MultiDataTrigger.Setters> </MultiDataTrigger> </Style.Triggers>
<Window.Resources> <Style x:Key="BigFontButton"> <Style.Setters> <Setter Property="Control.FontFamily" Value="Times New Roman"/> <Setter Property="Control.FontSize" Value="18"/> <Setter Property="Control.FontWeight" Value="Bold"/> </Style.Setters> <Style.Triggers> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:3" Storyboard.TargetProperty="FontSize" To="50"/> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> <EventTrigger RoutedEvent="Mouse.MouseLeave"> <EventTrigger.Actions> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:3" Storyboard.TargetProperty="FontSize"/> </Storyboard> </BeginStoryboard> </EventTrigger.Actions> </EventTrigger> </Style.Triggers> </Style> </Window.Resources> <Grid Name="gird1" ShowGridLines="True"> <Button HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource BigFontButton}">onesfsfsfsfsdfsdf</Button> </Grid>
标签:动画效果 anim cond focus 要求 animation targe mat 时间
原文地址:https://www.cnblogs.com/lovezhangyu/p/10229250.html