Search code examples
windows-phone

How to add fade in/out animation for making a Grid visible programmatically


I am working on a Windows phone app. I have a Grid which normally is Collapsed. But in some situation, I will programmatically change its visibility to become visible. My question is 'Is it possible to add some fade in/out animation for changing the panel from Collapsed to Visible? If yes, how can I do that?


Solution

  • You can animate the Opacity property of the Grid. When your grid is to be rendered visible you set the opacity to 0 and start the animation. Don't forget to set the visibility property to Visible before you start the animation and back to Collapsed when fading out.

    MSDN: Opacity animation