protected override void OnAppearing(){
ToolbarItem itemStudy = new ToolbarItem {
Name = "Study",
Order = ToolbarItemOrder.Primary,
Command = new Command (() => Navigation.PushAsync (studyPage))
};
if (ToolbarItems.Count > 0)
{
ToolbarItems.RemoveAt(0);
}
ToolbarItems.Add (itemStudy);
}
这是我在Xamarin上剪切的代码。用于添加Toolbaritem的表单。无论如何,我不认为这是一个优雅的方式,并寻找更好的解决方案。有人能帮忙吗?谢谢。
把这个添加到你的页面构造函数中:
ToolbarItem itemStudy = new ToolbarItem {
Name = "Study",
Order = ToolbarItemOrder.Primary,
Command = new Command (() => Navigation.PushAsync (studyPage))
};
ToolbarItems.Add(itemStudy);