In this article we will be seeing how to create Silverlight SkewTransform Animation using Visual studio 2010.In this we will be applying SkewTransform to an object based on one among the properties of the transform animation will be created. Skew Transform will be applied to Rectangle object and the AngleX property of the skew transform will be animated. For SkewTransform check http://www.c-sharpcorner.com/UploadFile/anavijai/4505/. Adding SkewTransform: <Rectangle x:Name="rectangle" Height="50" Width="50" Canvas.Left="75" Canvas.Top="75" Fill="Blue"> <Rectangle.RenderTransform> <SkewTransform x:Name="skewTransform"></SkewTransform> </Rectangle.RenderTransform> </Rectangle>Adding StoryBoard: <Storyboard x:Name="storyBoard"> <DoubleAnimation Storyboard.TargetName="skewTransform" Storyboard.TargetProperty="AngleX" From="-60" To="60" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True"> </DoubleAnimation> </Storyboard> Begin the Animation:storyBoard.Begin();Steps Involved:Creating a Silverlight Application: Open Visual Studio 2010. Go to File => New => Project. Select Silverlight from the Installed templates and choose the Silverlight Application template. Enter the Name and choose the location. Click OK. In the New Silverlight Application wizard check the "Host the Silverlight Application in a new Web site". Click OK. Creating the UI:Open MainPage.xaml file and replace the code with the following.<UserControl x:Class="SilverlightSkewTransformAnimation.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"><Canvas Height="200" Width="200" Background="White"> <Canvas.Resources> <Storyboard x:Name="storyBoard"> <DoubleAnimation Storyboard.TargetName="skewTransform" Storyboard.TargetProperty="AngleX" From="-60" To="60" Duration="0:0:3" RepeatBehavior="Forever" AutoReverse="True"> </DoubleAnimation> </Storyboard> </Canvas.Resources> <Rectangle x:Name="rectangle" Height="50" Width="50" Canvas.Left="75" Canvas.Top="75" Fill="Blue"> <Rectangle.RenderTransform> <SkewTransform x:Name="skewTransform"></SkewTransform> </Rectangle.RenderTransform> </Rectangle> </Canvas></UserControl>Open MainPage.xaml.cs file and replace the code with the following.public MainPage(){InitializeComponent();storyBoard.Begin();}Testing the solution: Build the solution. Hit ctrl+F5.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: