Implement key frames in wpf appication

Leave a Comment
create simple key frames animation in wpf application. I will give you demo with code also here so you can learn easily from here.

Main Window.
<Window x:Class="DesignSideAnnimation.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Content="Animated Me!!!" Width="50" Height="40" >
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard  >
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Width" Duration="0:0:5">
                                    <LinearDoubleKeyFrame Value="50" KeyTime="0:0:0"/>
                                 
                                    <LinearDoubleKeyFrame Value="200" KeyTime="0:0:3"/>
                                    <LinearDoubleKeyFrame Value="450" KeyTime="0:0:4"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                           
                        </BeginStoryboard>
                       
                    </EventTrigger.Actions>
                   
                   
                </EventTrigger>
               
               
            </Button.Triggers>
           
           
        </Button>
    </Grid>
</Window>
Output:


0 comments:

Post a Comment