Hi to all
I have a GridImageColumn and the only I have is the name of the image. So I add a IValueConverter.
The error I have is "Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object."
I read in https://help.syncfusion.com/xamarin/sfdatagrid/column-types, that GridImageColumn can show images from
What I am missing?
my code:
XAML:
<syncfusion:SfDataGrid x:Name="dataGrid" AllowSorting="True" SelectionMode="Single" ColumnSizer="Star" GridLongPressed="dataGrid_GridLongPressed" VerticalOptions="FillAndExpand">
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridImageColumn MappingName="{Binding PrimaryImage, Converter={StaticResource StrToImageLinkConverter}}" />
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
c#:
public class StrToImageLinkConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null)
{
string url = string.Format("http://mywebpage.com/images/{0}", value as string);
return new Uri(url);
}
else
{
return "";
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
Thanks in advance