I have a RadGridView which has two columns - A combobox column and image column. I need to change the image present in the image column based on the change in combobox column.
I have tried the following combination:
XAML :
<UserControl.Resources>
<local:Value2ImageURLConverter1 x:Key="GetImageURL"/>
</UserControl.Resources>
<telerik:RadGridView x:Name="radGrid"
ShowGroupPanel="False"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="20"
Grid.Row="2"
RowIndicatorVisibility="Collapsed"
AutoGenerateColumns="False"
ItemsSource="{Binding RandomAnswersList}"
<telerik:RadGridView.Columns>
<
telerik:GridViewDataColumn Header="Status Image" Width="90" IsReadOnly="True" >
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Image x:Name="img" Visibility="Visible" Source="{Binding Status,Converter={StaticResource GetImageURL}}" Width="100" Height="100"/>
<TextBlock Text="{Binding Status}">
</TextBlock>
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Status"
IsReadOnly="True"
DataMemberBinding="{Binding Status}">
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
XAML.cs
public
class Value2ImageURLConverter1 : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string appRoot = Application.Current.Host.Source.ToString().Substring(0, src.IndexOf("ClientBin"));
Image image = new Image();
if (value == null)
{
return new BitmapImage(new Uri(appRoot + "/Images/ExceptionRequest2.PNG", UriKind.RelativeOrAbsolute));
}
else if (value.Equals("Completed"))
{
return new BitmapImage(new Uri(appRoot + "/Images/Completed.PNG", UriKind.RelativeOrAbsolute));
}
else if (value.Equals("Outstanding"))
{
image.Source =
new BitmapImage(new Uri(appRoot + "/Images/Outstanding.PNG", UriKind.RelativeOrAbsolute));
}
return image;
//if (value != null)
//{
//return "/Images/ExceptionApproved.PNG";
//}
//else
//return "/Images/ExceptionRequest2.PNG";
//}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}