Click here to Skip to main content
15,882,412 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
VB
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:
HTML
<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
Posted
Comments
bat3a 3-Apr-12 20:37pm    
still no answer, come on guys, where are the pros.? please help. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900