【问题标题】:Showing a Save Toolbar Button in iOS using Xamarin Forms使用 Xamarin Forms 在 iOS 中显示保存工具栏按钮
【发布时间】:2014-09-14 05:15:43
【问题描述】:

我确信这是一件简单的事情,但不知何故我找不到任何关于它的好信息。使用 Xamarin 表单,我正在尝试在标题栏的右上角添加一个简单的保存工具栏按钮(在 iOS 中)。

我到底错过了什么? :D

Bonusproblem,我所有的图标都是灰色方块...

【问题讨论】:

    标签: ios xamarin xamarin.forms


    【解决方案1】:

    Page 具有用于此目的的 ToolBarItems 属性。您可以将ToolBarItems 添加到其中,它们将根据上下文可见(对于iOS,如果您的PageNavigationPage 中,它们将可见。

    所以这应该符合您的期望:

    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,
        });
    }
    

    【讨论】:

    • 是的,这很好用。我的问题是我试图设置 ToolbarItems 的页面位于 TabbedPage 中。我的坏...:D
    猜你喜欢
    • 2015-08-24
    • 1970-01-01
    • 2019-02-10
    • 2017-07-03
    • 1970-01-01
    • 2014-05-02
    • 2014-04-05
    • 2020-10-18
    • 1970-01-01
    相关资源
    最近更新 更多