Zoneur
Zoneur

Reputation: 1099

Show other view at application first launch

I have inherited some Windows Phone code that I must change. I need to show the user a tutorial about how to use the application when he first launches it. However, I cannot manage to change the current view...

Here is my code:

    public LoginView()
    {
        InitializeComponent();
        this.DataContext = new LoginViewModel();
        if (ApplicationFirstLaunched() == true)
        {
           NavigationManager.Current.Navigate(ApplicationView.DemoView);
        }
    }

The ApplicationFirstLaunched function works fine (I use IsolatedStorageSettings to store a boolean value), but the view never changes.. I thought that maybe the Navigate call was wrong so I created a button in my view and assigned its Click property to this function:

 private void demoBtn_Click(object sender, RoutedEventArgs e)
 {
    NavigationManager.Current.Navigate(ApplicationView.DemoView);
 }

When I click the button, the view changes and the tutorial pops up. What to do to show another view at first launch? Thanks

Upvotes: 3

Views: 103

Answers (1)

laszlokiss88
laszlokiss88

Reputation: 4081

Navigate in the OnNavigatedTo method.

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    if (ApplicationFirstLaunched() == true)
    {
       NavigationManager.Current.Navigate(ApplicationView.DemoView);
    }
}

Upvotes: 1

Related Questions