I know how to do it in WinForms
byte[] binaryData = Convert.FromBase64String(bgImage64);
image = Image.FromStream(new MemoryStream(binaryData));
In a situation I came across, I created a converter to handle the conversion of a Base64 string to WPF Image. So you can bind it to your base64 string property and let the converter handle the rest.
public class ByteToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if(string.IsNullOrEmpty(value.ToString())return;
var imgBytes = Convert.FromBase64String(value.ToString());
if (imgBytes == null)
return null;
using (var stream = new MemoryStream(imgBytes))
{
return BitmapFrame.Create(stream,
BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
}
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}