Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:wpf:control_transforms_and_animations [2010/12/10 16:25] smayr |
swdev:dotnet:wpf:control_transforms_and_animations [2010/12/10 16:31] (current) smayr [Animations] |
||
---|---|---|---|
Line 71: | Line 71: | ||
anim.DecelerationRatio = .33; | anim.DecelerationRatio = .33; | ||
btnSearch.BeginAnimation(Button.WidthProperty, | btnSearch.BeginAnimation(Button.WidthProperty, | ||
+ | </ | ||
+ | |||
+ | **Other Examples** | ||
+ | |||
+ | XAML: | ||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <Polygon Name=" | ||
+ | Points=" | ||
+ | Stroke=" | ||
+ | StrokeThickness=" | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | <Button Name=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | C#: | ||
+ | <code csharp> | ||
+ | private void btnAnimate_Click(object sender, RoutedEventArgs e) | ||
+ | { | ||
+ | AnimateEllipse(); | ||
+ | AnimateTriangle(); | ||
+ | } | ||
+ | |||
+ | private void AnimateEllipse() | ||
+ | { | ||
+ | TranslateTransform tt = new TranslateTransform(0, | ||
+ | |||
+ | DoubleAnimation daX = new DoubleAnimation(100, | ||
+ | new Duration(TimeSpan.FromMilliseconds(500)) | ||
+ | ); | ||
+ | |||
+ | DoubleAnimation daY = new DoubleAnimation(50, | ||
+ | new Duration(TimeSpan.FromMilliseconds(500)) | ||
+ | ); | ||
+ | |||
+ | tt.BeginAnimation(TranslateTransform.XProperty, | ||
+ | tt.BeginAnimation(TranslateTransform.YProperty, | ||
+ | |||
+ | shapeEllipse.RenderTransform = tt; | ||
+ | } | ||
+ | |||
+ | private void AnimateTriangle() | ||
+ | { | ||
+ | // Scale Transform | ||
+ | ScaleTransform scaletrans = new ScaleTransform(); | ||
+ | scaletrans.ScaleX = -1; | ||
+ | // | ||
+ | shapeTriangle.LayoutTransform = scaletrans; | ||
+ | |||
+ | // Translate Transform | ||
+ | TranslateTransform tt = new TranslateTransform(100, | ||
+ | shapeTriangle.RenderTransform = tt; | ||
+ | } | ||
</ | </ | ||
=== References === | === References === | ||
* [[http:// | * [[http:// | ||
+ | |||
== Control Triggering Animation of Another Control == | == Control Triggering Animation of Another Control == |