Using INavigationService (MVVM Light) vs Forms navigation

Is there any good reason of using the INavigationService in MVVM Light when working with forms?

Best Answers

Answers

  • Ed_SEd_S NLMember ✭✭

    @NMackay such a sample app would be interesting, thanks

  • ChrisNielsenChrisNielsen DKMember

    @NMackay That would be a big help!

  • kpantkpant USMember

    @NMackay - Any update on the sample app for Forms with MVVMLight that you were going to create?
    It will be very helpful if you can provide any sample.

  • NMackayNMackay GBInsider, University mod

    @Dev1Newgen

    Hi, on on annual leave for a few weeks, I have PM'd you a link for a sample app to get started using MVVM Light and Xamarin forms.

    There is also sample code on Laurents blog.

    http://blog.galasoft.ch/posts/

    I'm going to make a more fully featured app but I'm busy at work so have to do it in my spare time, anyway back to enjoying the wind and rain (and snow yesterday) in the Scottish Highlands.

  • SybexiaSybexia USMember, University

    @NMackay I too would be interested in a sample application using Xamarin Forms and MVVM Light

  • AndresCastroAndresCastro USMember

    @Sybexia I created a simple app recently using MVVM light and XF. Feel free to browse the code at https://github.com/acastr7/CheapSharkMobile

  • buchatskiybuchatskiy Member

    Personally I didn't enjoy NavigationService because it allows to pass only 1 rgument and force me to register Pages with some "keys". I prefer using clear Page constructor signatures with distinct arguments and Java-style callbacks like:
    Navigation.PushAsync(new SomeDetailPage(someId, (updSome) => {
    if (updSome != null) {
    ...
    }
    }), false);
    So I implemented a "proxy" wrapper which implements INavigation:
    public class AppNavigation : INavigation
    {
    public AppNavigation() { }
    protected INavigation Navigation => App.Current.MainPage?.Navigation;

                            public IReadOnlyList<Page> ModalStack => Navigation.ModalStack;
    
                            public IReadOnlyList<Page> NavigationStack => Navigation.NavigationStack;
    
                            public void InsertPageBefore(Page page, Page before)
                            {
                                Navigation.InsertPageBefore(page, before);
                            }
                            // etc ...
                        }
    

    and pass just INavigation to view models

Sign In or Register to comment.