Hi,
I don't know exactly that Image.Source can bind with BitmapImage.
But I did it using character sequence.
char[] can bind with the Image.Source.
here is the example.
XAML :
<Image
Source="{Binding ImageSource}"
/>
CS:
public bool ViewingImage(string subject)
{
string strPath = @"C:\Users\Public\Pictures\Sample Pictures\";
strPath += subject;
strPath += ".bmp";
ImageSource = LoadImageForTest(strPath);
return true;
}
private byte[] LoadImageForTest(string selectedFileName)
{
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.UriSource = new Uri(selectedFileName);
bitmapImage.EndInit();
byte[] data;
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
using (MemoryStream ms = new MemoryStream())
{
encoder.Save(ms);
data = ms.ToArray();
}
return data;
}
I hope that it will be helpful for you.
If you want more information, please contact me.
Thanks you