I have a problem with a WPF application.
I would like to bind a BitmapImage object which is inside a class into an Image object inside my XAML.
So I’m doing this way :
(I’m directly adding this class into the ListView) :
Public Sub New(ByVal Adress As String, ByVal ISAF As Boolean)
IWorking = showIcon(sName.Substring(sName.LastIndexOf(".")))
Dim IconMemStream As New MemoryStream
IWorking.ToBitmap.Save(IconMemStream, System.Drawing.Imaging.ImageFormat.Bmp)
sImage = New BitmapImage
sImage.BeginInit()
sImage.StreamSource = IconMemStream
sImage.EndInit()
IconMemStream.Close()
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs("Image"))
End Sub
And Inside the XAML I’m using this :
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Left">
<Image Source="{Binding Image}" Width="32" Height="32" />
<Label Content="{Binding Name}" />
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
The name shows but the bitmap not.
I checked if the sImage object had the bitmap, and it has.
But, the problem seems to be in the binding.
Any Ideas ?
This looks like what you are after: http://www.vbnettutorial.net/?Id=137&Desc=Wpf-Listbox-Image-Binding-From-Db