【发布时间】:2014-09-14 05:15:43
【问题描述】:
我确信这是一件简单的事情,但不知何故我找不到任何关于它的好信息。使用 Xamarin 表单,我正在尝试在标题栏的右上角添加一个简单的保存工具栏按钮(在 iOS 中)。
我到底错过了什么? :D
Bonusproblem,我所有的图标都是灰色方块...
【问题讨论】:
标签: ios xamarin xamarin.forms
我确信这是一件简单的事情,但不知何故我找不到任何关于它的好信息。使用 Xamarin 表单,我正在尝试在标题栏的右上角添加一个简单的保存工具栏按钮(在 iOS 中)。
我到底错过了什么? :D
Bonusproblem,我所有的图标都是灰色方块...
【问题讨论】:
标签: ios xamarin xamarin.forms
Page 具有用于此目的的 ToolBarItems 属性。您可以将ToolBarItems 添加到其中,它们将根据上下文可见(对于iOS,如果您的Page 在NavigationPage 中,它们将可见。
所以这应该符合您的期望:
public static Page GetMainPage ()
{
var label = new Label { Text = "content" };
return new NavigationPage (new ContentPage {
Title = "mypage",
ToolbarItems = {
new ToolbarItem {
Name = "Save",
Command = new Command (() => {
label.Text = "saved";
}),
}
},
Content = label,
});
}
【讨论】: