I have a string value in cs code from [Image]
column of mytable
in mydatabase
that type is varbinary(Max)
, now want to set value to source of Image control.
I wrote this code, but not set image to source :
string strImage = "0xFFD8FFE000104A46494600010....."
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
In constructor :
var bytes = GetBytes(strImage);
var myImage = new MyImageModel {Content = bytes};
MyImg.DataContext = myImage;
In Xaml:
<Image x:Name="MyImg" Source="{Binding Path=Content}"/>
The above code does not work and is not an error.