Changing the margin of a WPF Grid using animation
Here's my XAML, so far when someone enter any image in my Window, the animation pops up correctly.
<Style.Triggers> <EventTrigger RoutedEvent="Image.MouseEnter"> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:0.25" From="1" To="1.2" AutoReverse="True" Storyboard.TargetProperty="RenderTransform.ScaleX"/> <DoubleAnimation Duration="0:0:0.1" From="1" To="1.2" AutoReverse="True" Storyboard.TargetProperty="RenderTransform.ScaleY"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers>
Now I'd like to create another storyboard, one that fires on Image.MouseDown, however this time the animation should change the margin of a Grid called x:Name="container".
Can I access other controls properties inside a trigger? If so, how?
I can think of 2 options here:
- Create an EventTrigger for your Grid and set its SourceName property to Image name that fires MouseDown or it`s parent;
- Add another EventTrigger directly to the Image and set Storyboard.TargetName for animation to Grid`s name.