简体   繁体   中英

How do I use bind Viewmodels to bottomTabbed Viewpages in xamarin.forms?

I am using ViewModel.AutoWireViewmodel. So the tabbed view is already bound to a viewmodel. I don't know how bind my respective pages to their respective viewmodels

If you have bound your TabbedPage to a ViewModel, you can do it the same way for your other pages. Each page also has a BindingContext , so set each pages BindingContext to the ViewModel needed for each page.

MyPage1.cs Constructor:

public MyPage1()
{
    InitializeComponent();

    BindingContext = new MyPage1ViewModel();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM