User Tools

Site Tools


notes:uwp:animation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:uwp:animation [2017/04/12]
leszek
notes:uwp:animation [2018/05/08]
leszek
Line 1: Line 1:
 ====== Animation in UWP ====== ====== Animation in UWP ======
  
-Animation properties ​(adapted from the book "​Programming Windows, 6th edition"​ by Charles Petzold):+Animation properties:
  
   * The //​DoubleAnimation//​ element has to be a child of a //​Storyboard//​ element.   * The //​DoubleAnimation//​ element has to be a child of a //​Storyboard//​ element.
Line 31: Line 31:
  
   * An animation can be triggered in XAML rather than than in code-behind using an **EventTrigger**.   * An animation can be triggered in XAML rather than than in code-behind using an **EventTrigger**.
 +
 +  * When you animate a property which has the default value //​Double.NaN//,​ such as //Width// or //Height//, give the target element an explicit initial value, or add //​From/​To/​By//​ on the animation.
 +
 +  * A common reason of animation failing is to having a dependent animation that doesn'​t have //​EnableDependentAnimation//​ set to true. Also, keep in mind that the static property //​Timeline.AllowDependentAnimations//​=false globally disables all dependent animations.
  
  
Line 808: Line 812:
 Example: Use a **Storyboard** as a way to delay an operation: Example: Use a **Storyboard** as a way to delay an operation:
 <code csharp> <code csharp>
-// storyboard to update filter after a delay 
 Storyboard sb = new Storyboard();​ Storyboard sb = new Storyboard();​
 +...
 +// define
 sb.Duration = new Duration(TimeSpan.FromSeconds(1));​ sb.Duration = new Duration(TimeSpan.FromSeconds(1));​
 sb.Completed += (s, e) => sb.Completed += (s, e) =>
Line 815: Line 820:
     // ... perform a delayed operation here     // ... perform a delayed operation here
 }; };
 +...
 +// execute
 +sb.Stop();
 +sb.Seek(TimeSpan.Zero);​
 +sb.Begin();
 </​code>​ </​code>​
  
notes/uwp/animation.txt ยท Last modified: 2018/05/08 by leszek