⇤ ← Revision 1 as of 2019-06-25 23:01:51
Size: 1230
Comment:
|
Size: 533
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 7: | Line 7: |
1. Make the following folders in the .NET Standard project: 1. Services 1. TinyIoC 1. ViewModels 1. ViewModels/Base 1. Views 1. This project requires the TinyIoC project (don't get it from nuget, just include [[https://github.com/grumpydev/TinyIoC/blob/master/src/TinyIoC/TinyIoC.cs|this file]] in the TinyIoC folder. 1. In Services create the following Files and code: {{{#!highlight csharp public interface INavigationService { ViewModelBase PreviousPageViewModel { get; } Task InitializeAsync(); Task NavigateToAsync<TViewModel>() where TViewModel : ViewModelBase; Task NavigateToAsync<TViewModel>(object parameter) where TViewModel : ViewModelBase; Task RemoveLastFromBackStackAsync(); Task RemoveBackStackAsync(); } }}} |
First, take a look at the attached project. it is a bare minimum implementation that shows: 1. How to set your initial page in app.xaml 1. HOw to implement the Navigation services and base classes. |
Implementing Navigation Services in MVVM for Xamarin
This technique uses ViewModel first navigation which makes all the sense in the world if you are using MVVM. Otherwise, not so much. See: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/ for more details.
Steps
First, take a look at the attached project. it is a bare minimum implementation that shows:
- How to set your initial page in app.xaml
- HOw to implement the Navigation services and base classes.