我有一个 ListBox,我想用彩色Rectangle
滑出显示当前状态。
当项目是Selected
或 应该扩展时,它应该收缩MouseOver
。Recangle
<ControlTemplate.Resources>
<Storyboard x:Key="MoveOutStoryboard">
<DoubleAnimation To="175"
Storyboard.TargetProperty="Width"
Storyboard.TargetName="AnimatingGrid">
<DoubleAnimation.EasingFunction>
<QuinticEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<ColorAnimation Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
To="White" />
</Storyboard>
<Storyboard x:Key="MoveInStoryboard">
<DoubleAnimation To="16"
Storyboard.TargetProperty="Width"
Storyboard.TargetName="AnimatingGrid">
<DoubleAnimation.EasingFunction>
<QuinticEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<ColorAnimation Storyboard.TargetName="ContentPresenter"
Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"
To="Black" />
</Storyboard>
</ControlTemplate.Resources>
由于没有“或”多触发器,我想出了以下触发器:
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MoveOutStoryboard}" />
</Trigger.EnterActions>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MoveOutStoryboard}" />
</Trigger.EnterActions>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsSelected" Value="False" />
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MoveInStoryboard}" />
</MultiTrigger.EnterActions>
</MultiTrigger>
</ControlTemplate.Triggers>
但不知何故,MoveOutStoryboard
当我有最后一MultiTrigger
组时,从未调用过,但我不知道为什么。
谢谢你的帮助。