Sunday, September 2

Bounce Animation in C# DOTNET

Download Here:
Download Project Here
Video:
video





Screen Shots:

C# Code:



private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e) 
        { 
            ThicknessAnimation bounceAnimation = new ThicknessAnimation(); 
            BounceEase BounceOrientation = new BounceEase(); 
            BounceOrientation.Bounces = 4; 
            BounceOrientation.Bounciness = 2; 
            bounceAnimation.To = new Thickness(143,200,0,0); 
            bounceAnimation.From = new Thickness(143,0,0,0); 
            bounceAnimation.EasingFunction = BounceOrientation; 
            rectangle1.BeginAnimation(MarginProperty, bounceAnimation); 
        }


XAML Code:



<Window x:Class="BouncingAnimation.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> 
        <Rectangle Height="100" MouseDown="rectangle1_MouseDown" HorizontalAlignment="Left" Margin="143,0,0,0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top" Width="200"> 
            <Rectangle.Fill> 
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
                    <GradientStop Color="#FFD42626" Offset="0" /> 
                    <GradientStop Color="#FF550505" Offset="1" /> 
                </LinearGradientBrush> 
            </Rectangle.Fill> 
        </Rectangle> 
    </Grid> 
</Window> 


No comments:

Post a Comment