簡體   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