Using a Storyboard

One of the theme animations is called FadeOutThemeAnimation, and it knows how to make any element fade out. Let’s see how to apply that to a simple Button on a Page. This must be done with an object called a Storyboard. Storyboards can contain one or more animations and associate them with specific elements. Here’s a Page with the Button we want to animate and the Storyboard that provides context to the FadeOutThemeAnimation:

<Page ...>  <Page.Resources>    <Storyboard x:Name="storyboard" TargetName="b" >      <FadeOutThemeAnimation/>     </Storyboard>  </Page.Resources>  <Canvas Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">    <Button Name="b" >Animating Button</Button>  

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.