Create a simple animation using WPF.

Santhi
Posted by Santhi under WPF category on | Points: 40 | Views : 3419
Xaml Page code:
Try this :
<Page x:Class="ControlsWPFApplication.Animation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="Animation">

<Grid>
<Image Source="Images/hi.png" Stretch="Uniform" Margin="0,0,101,141" Height="50" Width="100" x:Name="hi">
<Image.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="hi" Storyboard.TargetProperty="Height" From="50" To="400" Duration="0:00:04"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="hi" Storyboard.TargetProperty="Width" From="50" To="400" Duration="0:00:04"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="hi" Storyboard.TargetProperty="Height" From="400" To="50" Duration="0:00:04"></DoubleAnimation>
<DoubleAnimation Storyboard.TargetName="hi" Storyboard.TargetProperty="Width" From="400" To="50" Duration="0:00:04"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
</Grid>
</Page>

Comments or Responses

Login to post response