hi
i have an SQL ce 3.5 database with an image field filled with a byte array, using the entity framework, i'm able to insert the image and to retrieve it from the db. through code in vb.net express 2010 successfully.
what i want to do is bind this field to a wpf image control so it update automatically when i update it in the db., i searchred through the net and all the converters proposed was using the value as string, while i get a byte array?
i have a converter class ready:
Public Class ImageConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim bitmap As New BitmapImage
Dim raw() As Byte = value
bitmap.BeginInit()
Dim memoryStream As New IO.MemoryStream(raw)
bitmap.StreamSource = memoryStream
bitmap.EndInit()
bitmap.Freeze()
Return bitmap
End Function
Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
and the bindings are:
<Image Name="Image1" Source="{Binding Path=eyeLeft, Converter=ImageConverter}" />
now i get a converting exception from byte to string.
is there a way to do this, thanks?
BTW:
i don't mind solution in c#, i'm using .net 4.0