This question is locked. New answers and comments are not allowed.
Hello all,
I've been experiencing some trouble displaying images in GridViewImageColumn. I think I have everything ok, but no image is displayed. The other columns are filled ok.
Here is my XAML code:
<telerik:RadGridView x:Name="AlarmGridView" EnableRowVirtualization="True" DataLoadMode="Asynchronous" ItemsSource="{Binding Events}"
RowStyleSelector="{StaticResource backgroundColorStyle}" ActionOnLostFocus="None"
IsReadOnly="True" AutoGenerateColumns="False" Grid.Row="1" HeaderRowStyle="{StaticResource GridViewHeaderRowStyle1}">
<telerik:RadGridView.Columns>
<telerik:GridViewImageColumn DataMemberBinding="{Binding evento, Converter={StaticResource ConvertEventToImage}}" >
<telerik:GridViewImageColumn.ToolTipTemplate>
<DataTemplate>
<TextBlock Text="{Binding evento}" />
</DataTemplate>
</telerik:GridViewImageColumn.ToolTipTemplate>
</telerik:GridViewImageColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding data}" Header="Data Hora" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding descricao}" Header="Descrição" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding evento}" Header="Evento" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding estado}" Header="Estado" IsVisible="False"/>
</telerik:RadGridView.Columns>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="GridContextMenu" Opened="GridContextMenu_Opened" >
<telerik:RadMenuItem Header="Marcar como Visto" Name="VistoMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Marcar como Novo" Name="NovoMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Iniciar Serviço" Name="ISMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Iniciar Viagem" Name="IVMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Observações" Name="ObsMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Aceitar Duplo-Click" Name="DCMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Fim de Viagem" Name="FVMenuItem" Visibility="Collapsed"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadGridView>
Here is my converter (just a stub):
public class ConverterFromEventToImage : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
BitmapImage image;
string Event = (string)value;
image = new BitmapImage(new Uri("male.jpg", UriKind.Relative));
return image;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
Is anything missing?
Thanks in advance.
Best regards,
Fernando
I've been experiencing some trouble displaying images in GridViewImageColumn. I think I have everything ok, but no image is displayed. The other columns are filled ok.
Here is my XAML code:
<telerik:RadGridView x:Name="AlarmGridView" EnableRowVirtualization="True" DataLoadMode="Asynchronous" ItemsSource="{Binding Events}"
RowStyleSelector="{StaticResource backgroundColorStyle}" ActionOnLostFocus="None"
IsReadOnly="True" AutoGenerateColumns="False" Grid.Row="1" HeaderRowStyle="{StaticResource GridViewHeaderRowStyle1}">
<telerik:RadGridView.Columns>
<telerik:GridViewImageColumn DataMemberBinding="{Binding evento, Converter={StaticResource ConvertEventToImage}}" >
<telerik:GridViewImageColumn.ToolTipTemplate>
<DataTemplate>
<TextBlock Text="{Binding evento}" />
</DataTemplate>
</telerik:GridViewImageColumn.ToolTipTemplate>
</telerik:GridViewImageColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding data}" Header="Data Hora" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding descricao}" Header="Descrição" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding evento}" Header="Evento" IsVisible="False" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding estado}" Header="Estado" IsVisible="False"/>
</telerik:RadGridView.Columns>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu x:Name="GridContextMenu" Opened="GridContextMenu_Opened" >
<telerik:RadMenuItem Header="Marcar como Visto" Name="VistoMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Marcar como Novo" Name="NovoMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Iniciar Serviço" Name="ISMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Iniciar Viagem" Name="IVMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Observações" Name="ObsMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Aceitar Duplo-Click" Name="DCMenuItem" Visibility="Collapsed"/>
<telerik:RadMenuItem Header="Fim de Viagem" Name="FVMenuItem" Visibility="Collapsed"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadGridView>
Here is my converter (just a stub):
public class ConverterFromEventToImage : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
BitmapImage image;
string Event = (string)value;
image = new BitmapImage(new Uri("male.jpg", UriKind.Relative));
return image;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
Is anything missing?
Thanks in advance.
Best regards,
Fernando