├── VMFirstNav ├── iOS │ ├── Resources │ │ ├── hamburger.png │ │ ├── hamburger@2x.png │ │ ├── Images.xcassets │ │ │ └── AppIcons.appiconset │ │ │ │ └── Contents.json │ │ └── LaunchScreen.xib │ ├── Entitlements.plist │ ├── packages.config │ ├── Main.cs │ ├── AppDelegate.cs │ ├── Info.plist │ └── VMFirstNav.iOS.csproj ├── Droid │ ├── Resources │ │ ├── drawable │ │ │ ├── icon.png │ │ │ └── hamburger.png │ │ ├── drawable-hdpi │ │ │ └── icon.png │ │ ├── drawable-xhdpi │ │ │ ├── icon.png │ │ │ └── hamburger.png │ │ ├── drawable-xxhdpi │ │ │ └── icon.png │ │ ├── AboutResources.txt │ │ └── Resource.designer.cs │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ ├── Assets │ │ └── AboutAssets.txt │ ├── MainActivity.cs │ ├── packages.config │ └── VMFirstNav.Droid.csproj ├── VMFirstNav │ ├── Models │ │ ├── IMasterListItem.cs │ │ └── MasterListItem.cs │ ├── ViewModels │ │ ├── Tabs │ │ │ ├── RootTabViewModel.cs │ │ │ ├── TabTwoChildViewModel.cs │ │ │ ├── TabTwoViewModel.cs │ │ │ ├── TabOneViewModel.cs │ │ │ └── TabOneChildViewModel.cs │ │ ├── Normal │ │ │ ├── NormalModalViewModel.cs │ │ │ ├── NormalOneViewModel.cs │ │ │ └── NormalOneChildViewModel.cs │ │ └── MasterDetail │ │ │ └── MasterListNavViewModel.cs │ ├── Views │ │ ├── IViewFor.cs │ │ ├── MasterDetailRootPage.xaml.cs │ │ ├── Tabs │ │ │ ├── TabOneView.xaml │ │ │ ├── TabTwoView.xaml │ │ │ ├── TabOneChildView.xaml │ │ │ ├── TabTwoChildView.xaml │ │ │ ├── TabOneView.xaml.cs │ │ │ ├── TabTwoView.xaml.cs │ │ │ ├── TabOneChildView.xaml.cs │ │ │ └── TabTwoChildView.xaml.cs │ │ ├── Normal │ │ │ ├── NormalOnePage.xaml │ │ │ ├── NormalModalPage.xaml │ │ │ ├── NormalOneChildPage.xaml │ │ │ ├── NormalOnePage.xaml.cs │ │ │ ├── NormalOneChildPage.xaml.cs │ │ │ └── NormalModalPage.xaml.cs │ │ ├── RootTabPage.xaml │ │ ├── MasterDetailRootPage.xaml │ │ ├── MasterDetail │ │ │ ├── MasterListNavPage.xaml.cs │ │ │ └── MasterListNavPage.xaml │ │ └── RootTabPage.xaml.cs │ ├── packages.config │ ├── Navigation │ │ ├── INavigationService.cs │ │ └── NavigationService.cs │ ├── VMFirstNav.cs │ ├── Converters │ │ └── SelectedItemEventArgsToSelectedItemConverter.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Behaviors │ │ └── ListViewSelectedItemBehavior.cs │ └── VMFirstNav.csproj └── VMFirstNav.sln ├── README.md ├── .gitignore └── LICENSE /VMFirstNav/iOS/Resources/hamburger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/iOS/Resources/hamburger.png -------------------------------------------------------------------------------- /VMFirstNav/iOS/Resources/hamburger@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/iOS/Resources/hamburger@2x.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable/icon.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable/hamburger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable/hamburger.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /VMFirstNav/Droid/Resources/drawable-xhdpi/hamburger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codemillmatt/XamFormsVMNav/HEAD/VMFirstNav/Droid/Resources/drawable-xhdpi/hamburger.png -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/Models/IMasterListItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MvvmHelpers; 3 | 4 | namespace VMFirstNav 5 | { 6 | public interface IMasterListItem where T : BaseViewModel 7 | { 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /VMFirstNav/iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /VMFirstNav/iOS/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/ViewModels/Tabs/RootTabViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MvvmHelpers; 3 | namespace VMFirstNav 4 | { 5 | public class RootTabViewModel : BaseViewModel 6 | { 7 | public RootTabViewModel() 8 | { 9 | Title = "Root Tabs"; 10 | } 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/Views/IViewFor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MvvmHelpers; 3 | 4 | namespace VMFirstNav 5 | { 6 | public interface IViewFor 7 | { 8 | object ViewModel { get; set; } 9 | } 10 | 11 | public interface IViewFor : IViewFor where T : BaseViewModel 12 | { 13 | T ViewModel { get; set; } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /VMFirstNav/Droid/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/Models/MasterListItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MvvmHelpers; 3 | namespace VMFirstNav 4 | { 5 | public class MasterListItem : IMasterListItem where T : BaseViewModel 6 | { 7 | public string DisplayName { get; set; } 8 | 9 | public MasterListItem(string displayName) 10 | { 11 | DisplayName = displayName; 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/Views/MasterDetailRootPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using Xamarin.Forms; 5 | 6 | namespace VMFirstNav 7 | { 8 | public partial class MasterDetailRootPage : MasterDetailPage 9 | { 10 | public MasterDetailRootPage() 11 | { 12 | InitializeComponent(); 13 | 14 | listNav.ViewModel = new MasterListNavViewModel(); 15 | normalOne.ViewModel = new NormalOneViewModel(); 16 | } 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XamFormsVMNav 2 | Xamarin Forms ViewModel First Navigation 3 | 4 | A library and example of how to do navigation in Xamarin forms only using view models! 5 | 6 | Blog posts explaining everything are below: 7 | * [Xamarin Forms - View Model First Navigation](https://codemilltech.com/xamarin-forms-view-model-first-navigation/) 8 | * [View Model First Navigation Part 2 - The Devil's In The Details](https://codemilltech.com/view-model-first-navigation-part-2-the-devils-in-the-details/) 9 | -------------------------------------------------------------------------------- /VMFirstNav/iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace VMFirstNav.iOS 9 | { 10 | public class Application 11 | { 12 | // This is the main entry point of the application. 13 | static void Main (string[] args) 14 | { 15 | // if you want to use a different Application Delegate class from "AppDelegate" 16 | // you can specify it here. 17 | UIApplication.Main (args, null, "AppDelegate"); 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /VMFirstNav/VMFirstNav/Views/Tabs/TabOneView.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 |