动态更改视觉状态DiscreteObjectKeyFrame值
本文关键字:DiscreteObjectKeyFrame 状态 视觉 动态 | 更新日期: 2023-09-27 17:59:21
我有列表项边框的可视化状态,如下所示:
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="ListItemBorder"
Storyboard.TargetProperty="Background">
// how to pass the value to here.
<DiscreteObjectKeyFrame KeyTime="0" Value="#c9vbf2"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
如何更改值c9vbf2
。我的AppResources
中有该值。
我正在处理WP8
您可以这样引用您的AppResource:
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ListItemBorder" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource YourCustomBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>