繁体   English   中英

如何使用 xamarin.forms 将两个 xaml 和 xaml.cs 文件绑定到一个 ViewModel?

[英]How to bind two xaml and xaml.cs files to one ViewModel using xamarin.forms?

我想知道是否有一种方法可以将两个 xaml 文件绑定到一个视图模型,以便允许从一个视图模型将数据绑定到两个 xaml 文件。

其实真的很简单

SomePage somePage = new SomePage(); //View 1 
SomeOtherPage otherPage= new SomeOtherPage();  // View 2
YourCommonViewModel commonVm = new YourCommonViewModel(); //Common VM

somePage.BindingContext = commonVm;
otherPage.BindingContext= commonVm;

希望这可以帮助

暂无
暂无

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

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