I currently have
<ContentControl Grid.Column="2" Grid.Row="3" > <ContentControl.Triggers> <EventTrigger RoutedEvent="UIElement.MouseEnter"> <BeginStoryboard Storyboard="{StaticResource ShakeStatorMinorRadiusEdit}"/> </EventTrigger> </ContentControl.Triggers> ... <snip> ... </ContentControl>
and
<Grid.Resources> <Storyboard x:Key="ShakeStatorMinorRadiusEdit"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StatorMinorRadiusEdit" Storyboard.TargetProperty="RenderTransform.X" RepeatBehavior="5x" > <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="3"/> <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0"/> <EasingDoubleKeyFrame KeyTime="0:0:0.20" Value="-3"/> <EasingDoubleKeyFrame KeyTime="0:0:0.25" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Grid.Resources>

The idea is that when the mouse enters the yellow highlighted control on the left, the yellow control on the right will tremble. The control on the right has x: Name = StatorMinorRadiusEdit Still works so well above.
Now I want to add one more complication. I just want the animation to start if the value in my view model is RotorLobes == 1. In an imaginary world, I would.
<ContentControl Grid.Column="2" Grid.Row="3" > <ContentControl.Triggers> <EventTrigger RoutedEvent="UIElement.MouseEnter"> <If Property="{Binding RotorLobes}" Value="1"/> <BeginStoryboard Storyboard="{StaticResource ShakeStatorMinorRadiusEdit}"/> </EventTrigger> </ContentControl.Triggers> ... <snip> ... </ContentControl>
In the real world, I have no idea how to achieve this.
c # wpf eventtrigger
bradgonesurfing
source share