Reputation: 10191
I'm trying to figure out how to successfully get Caliburn Micro to navigate from one page to another in a Windows Phone 8.1 app.
My first page loads just fine, as specified in my App class:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootViewFor<HomeViewModel>();
}
This launches the HomeView without issue. On that view I have a button that calls the following method:
public void GoToPage2()
{
this.navigationService.NavigateToViewModel<Page2ViewModel>();
}
This method is called when the button is pressed and the constructor for Page2ViewModel is called as well. The page just never displays and I can't figure out why. I feel like I'm missing a core concept, but I can't find any examples of how this should work.
Thanks for any help.
Upvotes: 4
Views: 651
Reputation: 10191
The solution is odd, and perhaps a bug in Caliburn Micro. In the OnLaunched method I used to have:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootViewFor<HomeViewModel>();
}
This worked and launched the home view, but subsequent navigation never worked. After comparing to a sample application I found, I changed the code to:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootView<HomeView>();
}
This also displays the home view, but now subsequent navigation works! I'm not sure why this would be the case, but at least I have an answer.
Upvotes: 5