简体   繁体   English

如何在xamarin.forms中将ViewModels绑定到bottomTabbed Viewpages?

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

I am using ViewModel.AutoWireViewmodel. 我正在使用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. 如果已将TabbedPage绑定到ViewModel,则可以对其他页面执行相同的操作。 Each page also has a BindingContext , so set each pages BindingContext to the ViewModel needed for each page. 每个页面还具有BindingContext ,因此将每个页面BindingContext设置为每个页面所需的ViewModel。

MyPage1.cs Constructor: MyPage1.cs构造函数:

public MyPage1()
{
    InitializeComponent();

    BindingContext = new MyPage1ViewModel();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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