I am trying to load a ListView thats binded to a database that brings a list of items. In the ListView i am showing two colums, "Items" and "Status." I am able to bring the values, but now I want to replace the value in Status to an Image.
Example:
1 = images/green.png
2 = images/red.png
3 = images/orange.png
And I would like to show the Image in the list, so as the user navigates, they see all the images automatically. I found something similar in another question but that has the image tag built in which I can't do in a ListView. WPF Convert Integer to Image without DB Binding
Thanks for Help.
EDIT
Partial Class ImgConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object
Dim imageIndex As Integer
If Integer.TryParse(value.ToString(), imageIndex) Then
Select Case imageIndex
Case 1
Return BitmapSource = "Images/green.png"
Case 2
Return BitmapSource = "Images/red.png"
End Select
End If
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object
Throw New NotImplementedException()
End Function
End Class
With this code I am getting a IntelliSense error BitmapSource and Implements IvalueConverter saying that I need to implement a ConvertBack, which I did but it still bugs me.
EDIT #3
OK THE BITMAPSOURCE ERROR WAS BC I DIDN'T DECLARE THE VARIABLE. THATS SOLVED.
The IValueConverter error says: Error 2 Class 'ImgConverter' must implement 'Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object' for interface 'System.Windows.Data.IValueConverter'. ...\Config (ABM,20)\RangoPage.xaml.vb 14 Cogent
Implements System.Windows.Data.IValueConverter.ConvertBack- ywm