View photo in Toolbaritem Xamarin Forms

Asked

Viewed 228 times

0

I need to display the photo on the right side of the menu with the ToolbarItem.

I return the photo from the database to the property "Photo" type string.

Convert the photo string to Base64 and attribute to the component Image of Xamarin Forms.

In another View, this process works perfectly, but now I need to display it in Toolbaritem.

How can I do this ?

My code:

\\ XAML

<ContentPage.ToolbarItems>
    <ToolbarItem Name="Menu2" Order="Primary" Priority="1">
      <ToolbarItem.Icon>
      </ToolbarItem.Icon>
    </ToolbarItem>
  </ContentPage.ToolbarItems>

\\ .CS

byte[] imageBytes;
var FileImage = new Image();
imageBytes = Convert.FromBase64String(Foto);
FileImage.Source = ImageSource.FromStream(() => new MemoryStream(imageBytes));

I need to show the photo here:

inserir a descrição da imagem aqui

  • What’s the problem with your current code?

  • @Genos So, even the part of Fileimage has no problem. I don’t know how to assign this Fileimage pro icone from Toolbaritem

1 answer

1

The estate Icon gets a ImageSource.

this.ToolbarItems.Add (new ToolbarItem () { Icon = ImageSource.FromStream(() => new MemoryStream(imageBytes))});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.