I'm trying to display an image I have saved as a resource under the properties category.
This property however returns a byte[] which can't be displayed by <Image> since it can't convert it to ImageSource.
The code looks like this:
public byte[] MyImage = Properties.ImageResources.MyImage
but plugging MyImage into
<Image Source="{x:Bind MyImage}"
gives me a conversion error as described above.
I've already tried converting the image to a bitmap to display this instead, but I got the very same error. I've read alot about something like
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
but then it tells me it can't resolve any of the BitmapImage Functions -> BeginInit, EndInit, StreamSource and CacheOption.
I've searched far and wide but they all end in this BeginInit() and EndInit() function which do not exist for me.
Thanks to the help of EldHasp I've found a way to make the images appear.
I have created a data binding converter class that implements the
IValueConverterinterface:Or shorter:
It would be used in XAML e.g. like shown below, when
MyImageis a public property of the object in the DataContext of the Grid: