I'm trying to Invoke NavigateTo
in Windows 8.1 Universal app outside of the wiew model. I already tried:
var dispatcher = Window.Current.Dispatcher;
await dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async () => await NavigateToRegistrationPage()
);
Resulting with exception thrown
Object reference not set to instance of object.
I also tried Using Messenger to invoke navigation form ViewModel via messenger message:
Messenger.Default.Send<MessengerEvents.NavigateToRegistrationPage>(
new MessengerEvents.NavigateToRegistrationPage()
);
Public LoginViewModel //...
MessengerInstance.Register<MessengerEvents.NavigateToRegistrationPage>(
this,
(message) => GoToRegistrationPage()
);
Doesn't work either.
Error has been thrown by the target of invocation
I cant invoke navigation directly in viewmodel (checked without messenger called directly from the view model works perfectly) as navigation is performed in response to server message.
private void GoToRegistrationPage()
{
NavigationService.NavigateTo(ResourceService.CHOOSE_REGISTRATION_PAGE);
}
ServiceLocator.Current.GetInstance<INavigationService>();
would be the code most likely – Depechie