Search code examples
silverlightwindows-phone-7xamlwindows-phone-8expression-blend

Finish transition effect


I have a menu that shows up and hides with transition effects:

Open

Closed

The elements you see are navigating you to other pages.

So when i navigate to other page i do:

MenuButton.Tag = "MenuDisabled";
        VisualStateManager.GoToState(this, "HideMenu", true);
        NavigationService.Navigate(new Uri("/AboutPageAuthorized.xaml", UriKind.Relative));

But it happens that navigation is working faster than effect, so you will see it sliding till the middle and then fast dissapear - its annoying.

Is there a way to handle this effect breaking thing?


Solution

  • Add a delay before you call the navigation, you can add the delay using System.Timers Just add the navigation event under OnTimedEvent, and adjust the timer according to your needs.

    //Place the effect here
    
    // Create a timer with a ten second interval.
    aTimer = new System.Timers.Timer(10000);
    
    // Hook up the Elapsed event for the timer.
    aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
    
    // Set the Interval to 2 seconds (2000 milliseconds).
    aTimer.Interval = 2000;
    aTimer.Enabled = true;
    
    private static void OnTimedEvent(object source, ElapsedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/AboutPageAuthorized.xaml", UriKind.Relative));
    }