I have a ListBox where I want to display the current State with a colored Rectangle
sliding out.
When The Item is Selected
or MouseOver
the Recangle
should extend otherwise it should shrink.
<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>
As there is no 'or' Multitrigger I figured out the following Trigger:
<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>
But Somehow the MoveOutStoryboard
is never called when I have the last MultiTrigger
set, but I cannot figure out why.
Thanks for yor help.
since another animation can not take control over a property unless started by the same trigger, so give this a try
if you face the issue with mouse over and IsSelected then use this
also remove the multitrigger, that may not be necessary, or you can combine the remove storyboard approach in with your approach, that should work too.
EDIT
here is your approach with the RemoveStoryboard, this is working, I tested too
or this, but this may be buggy and you can see some snaps in animation