我有这样的遍历控制模板在Silverlight
<ControlTemplate TargetType="Button">
<Grid >
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<!--Take one half second to trasition to the MouseOver state.-->
<VisualTransition To="MouseOver"
GeneratedDuration="0:0:0.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<!--Change the SolidColorBrush, ButtonBrush, to red when the
mouse is over the button.-->
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBrush"
Storyboard.TargetProperty="Color" To="Red" />
</Storyboard>
</VisualState>
**<VisualState x:Name="SelectedButton">
<Storyboard x:Name="SelectedButtonStoryboard">
<ColorAnimation Storyboard.TargetName="ButtonBrush"
Storyboard.TargetProperty="Color" To="Red" />
</Storyboard>
</VisualState>**
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.Background>
<SolidColorBrush x:Name="ButtonBrush" Color="Green"/>
</Grid.Background>
</Grid>
</ControlTemplate>
我已经遍历该控件模板获得命名SelectedButtonStoryboard
故事板或获得的可视状态SelectedButton
和调用任何一个控件模板。
请帮忙。提前致谢。
其实,如果我更具体地说,我需要故事板。有没有办法在Silverlight中遍历控件模板? –
但你为什么需要故事板?这听起来对你而言,你想从一种UI状态播放一些动画到另一种。为此,你应该使用VisualStates。 – Oliver