我正在學習 Xamarin,我試圖了解如何將值從我的類檔案傳遞到 .xmal 檔案以進行顯示?是資料系結還是別的什么。
示例:我的檔案.cs
namespace MyApp.Views
{
public partial class LandingPage : ContentPage
{
public LandingPage()
{
string myvalue = "hello world";
}
}
}
檔案.xaml
<StackLayout>
<Label Text="myvalue" />
</StackLayout>
我希望“myvalue”從我??的班級傳遞到我的 xaml 檔案。
uj5u.com熱心網友回復:
是的,資料系結就是答案
<Label Text="{Binding MyValue}" />
您只能系結到公共屬性
public string MyValue { get; set; }
public LandingPage()
{
InitializeComponent();
MyValue = "hello world";
this.BindingContext = this;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/422321.html
標籤:
上一篇:秒表不會停止
