Created
April 7, 2015 17:16
-
-
Save anonymous/643e62ad97af2c4b1f07 to your computer and use it in GitHub Desktop.
Xamarin Forms TabbedPage Code Snippet
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 MainViewModel : ViewModelBase | |
{ | |
public MainViewModel( | |
DashboardViewModel dashboardViewModel, | |
JournalViewModel journalViewModel, | |
RestaurantsViewModel restaurantsViewModel) | |
{ | |
Dashboard = dashboardViewModel; | |
Journal = journalViewModel; | |
Restaurants = restaurantsViewModel; | |
} | |
public DashboardViewModel Dashboard { get; set; } | |
public JournalViewModel Journal { get; set; } | |
public RestaurantsViewModel Restaurants { get; set; } | |
} | |
<TabbedPage> | |
<TabbedPage.Children> | |
<DashboardPage BindingContext="{Binding Dashboard}" /> | |
<JournalPage BindingContext="{Binding Journal}" /> | |
<RestaurantsPage BindingContext="{Binding Restaurants}" /> | |
</TabbedPage.Children> | |
</TabbedPage> | |
builder.RegisterType<MainViewModel>(); | |
builder.RegisterType<DashboardViewModel>(); | |
builder.RegisterType<JournalViewModel>(); | |
builder.RegisterType<JournalViewModel>(); | |
builder.RegisterType<MainView>(); | |
builder | |
.RegisterAssemblyTypes(typeof(MainViewModel).GetTypeInfo().Assembly) | |
.Where(i => i.IsAssignableFrom(typeof(ViewModelBase))) | |
.AsSelf(); | |
protected override void RegisterViews(IViewFactory viewFactory) | |
{ | |
viewFactory.Register<MainViewModel, MainView>(); | |
} | |
protected override void ConfigureApplication(IContainer container) | |
{ | |
var viewFactory = container.Resolve<IViewFactory>(); | |
var mainPage = viewFactory.Resolve<MainViewModel>(); | |
_application.MainPage = mainPage; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment