BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.MappingName = "DealerImage";
templateColumn.CellTemplate = new DataTemplate(() =>
{
Frame frame = new Frame();
Image image = new Image();
image.Source = ImageSource.FromResource("DataGridDemo.Image2.png");
image.HeightRequest = 25;
image.WidthRequest = 25;
image.HorizontalOptions = LayoutOptions.Center;
image.VerticalOptions = LayoutOptions.Center;
frame.Content = image;
frame.Padding = 0;
return frame;
});
sfGrid.Columns.Add(templateColumn);
private void OnDataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e)
{
if (e.RowIndex != 0)
{
if (e.Height != sfGrid.RowHeight)
return;
GridRowSizingOptions options = new GridRowSizingOptions();
options.ExcludeColumns.Add("DealerImage");
e.Height = sfGrid.GetRowHeight(e.RowIndex, options);
e.Handled = true;
}
} |
Hi Andreas,Thanks for contacting Syncfusion Support.We checked your query and your requirement to load the images in the fixed size cannot be achieved in GridImageColumn, however it can be achieved by using theSfDataGrid.GridTemplateColumn. You can load the image in the Frame and set the HeightRequest, WidthRequest, HorizontalOptions, VerticalOptions to the Image and padding to the Frame to which image is added as the child. You also need to exclude the image column while querying row height. Please find the code snippet of the same below.
GridTemplateColumn templateColumn = new GridTemplateColumn();templateColumn.MappingName = "DealerImage";templateColumn.CellTemplate = new DataTemplate(() =>{Frame frame = new Frame();Image image = new Image();image.Source = ImageSource.FromResource("DataGridDemo.Image2.png");image.HeightRequest = 25;image.WidthRequest = 25;image.HorizontalOptions = LayoutOptions.Center;image.VerticalOptions = LayoutOptions.Center;frame.Content = image;frame.Padding = 0;return frame;});sfGrid.Columns.Add(templateColumn);private void OnDataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e){if (e.RowIndex != 0){if (e.Height != sfGrid.RowHeight)return;GridRowSizingOptions options = new GridRowSizingOptions();options.ExcludeColumns.Add("DealerImage");e.Height = sfGrid.GetRowHeight(e.RowIndex, options);e.Handled = true;}}
We have prepared the sample to achieve your requirement, you can download the same from the below link.Regards,Vigneshkumar R