1
votes

I'm sure this is a simple thing to do, but somehow I cannot find any good information about it. Using Xamarin Forms, I'm trying to add a simple Save toolbar button (in iOS) to the top right in the title bar.

What in the world am I missing? :D

Bonusproblem, all my icons are grey squares...

1

1 Answers

4
votes

Page has a ToolBarItems property which serves this purpose. You can add ToolBarItems to it and they will be visible depending on the context (for iOS, they'll be visible if your Page is in a NavigationPage.

So this should do what you expect:

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

enter image description here