我想標題添加到導航欄,如果我指定的XAML頁面標題,正在顯示它,但我想我的C#代碼執行過程中添加標題。如何添加標題到內容頁編程xamarin形式?
我曾嘗試以下不已: 1.標題=組名; 2. SetBinding(Page.TitleProperty,組名);
TIA
更新:
Device.BeginInvokeOnMainThread(() => { Title = groupName; });
工作就像一個魅力。感謝傑拉德。
我想標題添加到導航欄,如果我指定的XAML頁面標題,正在顯示它,但我想我的C#代碼執行過程中添加標題。如何添加標題到內容頁編程xamarin形式?
我曾嘗試以下不已: 1.標題=組名; 2. SetBinding(Page.TitleProperty,組名);
TIA
更新:
Device.BeginInvokeOnMainThread(() => { Title = groupName; });
工作就像一個魅力。感謝傑拉德。
要更新UI,你需要在UI線程上運行它。您可以通過包裝標題的設置在呼叫這樣做BeginInvokeOnMainThread,這樣的:標題
在你的頁面構造給像下面
public UserRegistration()
{
InitializeComponent();
Title = "HomePage";
//Connecting context of this page to the our View Model class
this.BindingContext = App.Locator.Register;
}
的頭銜,我嘗試過。它從來沒有工作。謝謝@venkata – summerGhost
環繞設定在'Device.BeginInvokeOnMainThread(()=> {標題=「新頭銜」;} );' –
它非常完美。從來沒有在'BeginInvokeOnMainThread'上工作。現在知道它就像在本機android中的'RunOnUiThread'。謝謝@GeraldVersluis – summerGhost
它更新一個答案,請接受:) –