我有一个子类ListBox
,其SelectedItemChanging
依赖属性设置为Storyboard
. 更改所选项目时,我想Storyboard
在ListBox
.
这怎么可能与单个实例Storyboard
?
我有一个子类ListBox
,其SelectedItemChanging
依赖属性设置为Storyboard
. 更改所选项目时,我想Storyboard
在ListBox
.
这怎么可能与单个实例Storyboard
?
WPF 故事板有一个Clone 方法。Silverlight 没有这个,但我想我会发布它,以防有人偶然发现这篇文章寻找 WPF 解决方案。
故事板可以键控并从多个触发器运行,只要设置正确,它就可以很好地工作。如果我对您的理解正确,您希望将情节提要应用到每个单独的 ListBoxItem。在这种情况下,为什么不制作一种风格,并在该风格的触发器上触发情节提要。
原谅我的伪代码。
<Storyboard x:Key="MyEnterStoryboard">
<!-- Do Enter Work -->
</Storyboard>
<Storyboard x:Key="MyExitStoryboard">
<!-- Do Exit Work -->
</Storyboard>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Triggers>
<Trigger Property="SelectedItemChanging" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MyEnterStoryboard}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource MyExitStoryboard}"/>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>