How to include new right icon in a Xamarin Forms activity

1

Is it possible to include a new icon in a activity but on the right, without changing the existing one?

I need to include the user's photo on the right.

(Red place in the image)

Image:

    
asked by anonymous 02.12.2016 / 20:00

2 answers

1

It is possible to do so, you need to add a new "ToolbarItem" to your taskbar. If you are developing the page directly in C # you can do it as follows

this.ToolbarItems.Add(new ToolbarItem("nome", "icone", () => 
        {
            // ação ao clicar no icone
        }, ToolbarItemOrder.Primary));

Where:

  • The "name" would be the name to appear when the user presses and holds the icon, or if there is no icon image, in this case the text is extended.

  • The "icon" would be the icon that you will use for the option, in this case the user image

  • And the "ToolbarItemOrder.Primary" is to indicate the position that the item will be in the menu, if you put "ToolbarItemOrder.Secondary" the item will be in a menu of options (The same place you usually find the "Settings" of an app, that menu with three dots "..."), already if you put "ToolbarItemOrder.Primary" it will show as an item in the menu, showing the icon that you defined to him or the photo of the user in your case =)

I hope I have helped =)

    
05.12.2016 / 03:17
2

One way would look like this:

<ContentPage.ToolbarItems>
        <ToolbarItem Text="Usuario" Order="Primary" Priority="0">
            <ToolbarItem.Icon>
                <OnPlatform x:TypeArguments="FileImageSource"
                    WinPhone="Toolkit.Content/imagem.png"
                    Android="imagem.png"
                    iOS="imagem.png"
                    />
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>
    
04.12.2016 / 14:23