Hi,
I have a RadGridView that gets bound to a DataTable (aside: this may not be the proper way to bind, but the UserControl is passed _wg) with this line:
rgvGrid.ItemsSource = _wg.GridData.Tables[0];
One of the columns has a string that I'd like to show an image dependant on what the string is. A job for a converter I thought...
My Converter class is (I've taken out the case statements to ensure an image is returned):
My xaml file contains:
This doesn't work. When I add the converter to DataMemberBinding (as shown above), the program enters the converter, but it doesn't enter the converter if I simply have it listed in the Image Source line (also shown).
Have you any suggestions how to get this to work?
Thanks
I have a RadGridView that gets bound to a DataTable (aside: this may not be the proper way to bind, but the UserControl is passed _wg) with this line:
rgvGrid.ItemsSource = _wg.GridData.Tables[0];
One of the columns has a string that I'd like to show an image dependant on what the string is. A job for a converter I thought...
My Converter class is (I've taken out the case statements to ensure an image is returned):
public
class
RequestColumnConverter : IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
if
(value !=
null
)
{
string
name = (
string
)value;
var requestImage =
new
Image()
{
Height = 16,
Width = 16,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
};
requestImage.Source =
new
BitmapImage(
new
Uri(
"pack://application:,,,/Images/service.png"
));
return
requestImage;
}
else
return
null
;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
return
null
;
}
}
My xaml file contains:
<
telerik:GridViewDataColumn
Header
=
"Type"
IsReadOnly
=
"True"
UniqueName
=
"SCSRequestTypeName"
DataMemberBinding
=
"{Binding Path=SCSRequestTypeName, Converter={StaticResource requestColumnConverter}}"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
Image
Source
=
"{Binding SCSRequestTypeName, Converter={StaticResource requestColumnConverter}}"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
Have you any suggestions how to get this to work?
Thanks