【发布时间】:2013-01-28 04:30:03
【问题描述】:
我为控件模板中的按钮定义了一个 VisualState:
<ControlTemplate x:Key="ButtonTemplate" TargetType="Button">
...
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
...
<VisualState x:Name="PointerOver">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="c1" Storyboard.TargetProperty="Opacity" To="0.7"/>
</Storyboard>
</VisualState>
...
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
...
</ControlTemplate>
但是应该根据视图模型条件启用/禁用此效果(鼠标悬停时更改不透明度),那么我该如何使用 XAML 做到这一点?
我尝试为 DoubleAnimation 的 To 值创建绑定,但它不起作用,因为 Storyboard 已冻结。我也在想模板选择器之类的东西,但是VisualState Manager没有这样的东西。
【问题讨论】:
标签: xaml windows-runtime windows-store-apps visualstatemanager