Category / Section
How to change the size of the sort icon in Xamarin DataGrid (SfDataGrid)?
4 mins read
SfDataGrid allows you to modify the size of the SortIcon header. This can be achieved by overriding OnInitializeDisplayView method in custom SfDataGrid.GridHeaderCellRenderer and changing the size of its parent element.
public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); dataGrid.CellRenderers.Remove("HeaderView"); dataGrid.CellRenderers.Add("HeaderView", new HeaderCellRenderer()); } } public class HeaderCellRenderer: GridHeaderCellRenderer { public override void OnInitializeDisplayView(DataColumnBase dataColumn, ContentView view) { base.OnInitializeDisplayView(dataColumn, view); ((view as BorderView).Content as Grid).ColumnDefinitions[1].Width = new GridLength(20, GridUnitType.Absolute); } }
View sample in GitHub