0

I'm using MVVM Light Toolkit to build an app in windows phone 8.1, When I use Navigation Service's NavigateTo method my app close without throwing an error. This issue seems to be randomly.

I'm using the typical MVVM architecture. I Use a ViewModelLocator in which I use unity to register all my dependencies.

Alcruz
  • 537
  • 5
  • 12

2 Answers2

1

Here is the (shorted) code of the NavigateTo method implementation:

public virtual void NavigateTo(string pageKey, bool persist = true)
{
    if (!_pagesByKey.ContainsKey(pageKey))
        throw new ArgumentException(string.Format("No such page: {0}. Did you forget to call NavigationService.Configure?", pageKey), "pageKey");
    ((Frame)Window.Current.Content).Navigate(_pagesByKey[pageKey]);
}

So this method can only crash if you forgot to configure the page you are trying to navigate to, or if the Navigate method of the WP frame fails.

Florian Moser
  • 2,583
  • 1
  • 30
  • 40
  • Actually the problem was in a race condition in my code when some pages were opening. Thanks. – Alcruz Jun 13 '16 at 15:53
0

Try to use Dispatcher with navigation:

await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => Frame.Navigate( typeof( SomePage ), "PageAgrs" ) );
crea7or
  • 4,421
  • 2
  • 26
  • 37