我正在尝试使用CommonStates
来为我的用户控件设置动画。我尝试了以下方法:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="circle"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
EnableDependentAnimation="True">
<LinearColorKeyFrame Value="Red"
KeyTime="0:0:0.02" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="circle"
Height="280"
Width="280"
Fill="Green" />
</Grid>
我可以通过手动调用来产生更改UpdateStates(true)
,但是参考文档应该自动触发 commonstates。
知道我做错了什么吗?