GridImageColumn image from URL

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

1 Reply

JA Jayaraman Ayyanar Syncfusion Team April 16, 2018 11:53 AM UTC

 
Thanks for using Syncfusion products. 
 
We have checked your query for “GridImageColumn image using converter”. In the provided code snippet, you have set the converter for the MappingName which is not valid. If you want to set the image using the converter, you should set using the DisplayBinding property for the GridImageColumn, to populate the image. We have provide a sample to achieve your requirement, by getting the image from ImageSource.FromResource, like the same you can set using the url image.  
 
We have attached the sample and you can download the same from the below link: 
 
Regards, 
Jayaraman. 


Loader.
Up arrow icon