Hello, the animation you want can be created from the following structure:
<Grid x:Name="Background">
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.Loaded">
<BeginStoryboard>
<Storyboard>
<ThicknessAnimation Storyboard.TargetProperty="item1" From="item2" To="item3" DecelerationRatio="0.9" Duration="0:0:0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
Explaining Best
Within your control (in the case of the grid), you add the container Triggers (trigger) that will trigger your event, then set EventTrigger as container and BeginStoryBoard to populate what happens at the start of the event and RoutedEvent gets the name of the target control of the animation and its trigger, the structure may change depending on the animation you want .
item1 is the target property, where the animation will be applied.
item2 the initial value of this property.
item3 the final value of this property.
Duration is the duration time of the animation, in the example above it is 1/2 of a second.
for more details:
link
link
source:
link