mvvmwindows-phone-8.1mvvm-lightmvvm-toolkit

My app close when navigate to another page on windows phone 8.1


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.


Solution

  • 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.