Childwindow animation RRS feed

  • Question

  • In the default Silverlight Business Application (silverlight 4 in VS2010) I can see the login window is popping up and when closing it is popping out.

    Whenever you click the "Register new" link the contents of the login window (a stackpanel) is flipped with the content of the registration form (also a stackpanel)

    ? 1: Where is this 'flip' animation set ? I am still a bit new to silverlight (and xaml), and I can;t find the definition of this flip animation

    ? 2: Can such animation be easily set as default for a child window ? I mean without 100's of lines of extra code. I would prefere to set a property of the child window to "Popup","Fade", "Flip"  etc.

    Some hints would be very welcome.


    Thursday, May 12, 2011 8:50 AM

All replies

  • Hi,

    The flip animation can be done with the help of PlaneProjection from the namespace System.Windows.Media.Animation.You can find the flip animation set into those xaml pages which are currently using the flip animation. Please go through the following code:

       <PlaneProjection x:Name="Projection"/>

    And in the code behind, add a double animation storyboard to flip the page using the following code:

    DoubleAnimation daY1 = new DoubleAnimation { From = 0.00, To = 90.00 };
    Storyboard.SetTargetName(daY1, "Projection");
    Storyboard.SetTargetProperty(daY1, new PropertyPath("RotationX"));
    this.Resources.Add("EndOfPage", stb1);
    Storyboard stb = new Storyboard();
    stb.Duration = new Duration(TimeSpan.FromSeconds(1));
    stb.SpeedRatio = 3;
    DoubleAnimation daY = new DoubleAnimation { From = -90.00, To = 0.00 };
    Storyboard.SetTargetName(daY, "Projection");
    Storyboard.SetTargetProperty(daY, new PropertyPath("RotationX"));
    this.Resources.Add("StartOfPage", stb);

    Using the following method, we can navigate from page to page:

    public void SwitchToPage(UserControl p)
        NextPage = p;
        if (CurrentPage != p)
            Storyboard currStb = CurrentPage.Resources["EndOfPage"] as Storyboard;
            currStb.Completed += new EventHandler(currStb_Completed);


    Sunday, June 5, 2011 1:49 AM