我有這樣的遍歷控制模板在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