How to convert string to Fileimagesource(Icon) Xamarin Forms

Asked

Viewed 119 times

1

How to convert a string(Image) to FileImageSource(Icon) ?

I need to display a photo on ToolbarItems in the right corner of the hamburger menu.

I tried that way, but it didn’t work. My code:

FileImageSource IconFoto = new FileImageSource();

IconFoto = Foto; // Imagem retornada do BD como string

this.ToolbarItems.Add(new ToolbarItem("nome", IconFoto, () =>
{
}, ToolbarItemOrder.Primary));

1 answer

1

I imagine your "string" is a base 64 , so :

this.ToolbarItems.Add (new ToolbarItem () { Icon = ImageSource.FromStream(() => new MemoryStream(imageBytes))});
  • I tried to use this however, it gives image source to fileimagesource conversion error. Then he asks to cast a cast, then I cast and execute the conversion error.

  • its string is a base 64 ?

Browser other questions tagged

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