Created
June 18, 2014 02:29
-
-
Save rid00z/a0f4599e54c10e07afc1 to your computer and use it in GitHub Desktop.
A RootNavigation page for a Mvvm in Xamarin.Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RootContainerPage : MasterDetailPage, IRootNavigation | |
{ | |
ContentPage _menuPage; | |
NavigationPage _contactNavPage, _quotesNavPage; | |
public RootContainerPage () | |
{ | |
_contactNavPage = new NavigationPage (BasePageModel.ResolvePageModel<ContactsRootPageModel> (null)); | |
_quotesNavPage = new NavigationPage (BasePageModel.ResolvePageModel<QuotesRootPageModel> (null)); | |
Detail = _contactNavPage; | |
_menuPage = new ContentPage (); | |
_menuPage.Title = "Menu"; | |
var listView = new ListView(); | |
listView.ItemsSource = new string[] { "Contacts", "Quotes" }; | |
listView.ItemSelected += (sender, args) => | |
{ | |
if ((string)args.SelectedItem == "Contacts") | |
Detail = _contactNavPage; | |
if ((string)args.SelectedItem == "Quotes") | |
Detail = _quotesNavPage; | |
IsPresented = false; | |
}; | |
_menuPage.Content = listView; | |
Master = new NavigationPage(_menuPage) { Title = "Menu" }; | |
} | |
public void PushPage (Page page, BasePageModel model) | |
{ | |
((NavigationPage)Detail).PushAsync (page); | |
} | |
public void PopPage () | |
{ | |
((NavigationPage)Detail).PopAsync (); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment