Hi Kumaraswamy,
In SfDataGrid, we have maintained separate renderers for separate views in dictionaries (with key and value pair). For example, in GridSwitchColumn, we have loaded SfSwitchControl which is derived from Xamarin.Forms.Switch and we customized the switch view in renderer projects separately where we have loaded native switch controls for Android, iOS and UWP.
Also, you can customize those renderers by writing your own custom renderer. For that, you have to remove the existing renderer from the GridCellRenderer collection and add your custom renderer. Please refer the below code snippet.
// In code-behind
dataGrid.CellRenderers.Remove("Switch");
dataGrid.CellRenderers.Add("Switch",new CustomSwitchRenderer());
public class CustomSwitchRenderer : GridCellSwitchRenderer
{
public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfSwitchControl view)
{
base.OnInitializeDisplayView(dataColumn, view);
view.IsEnabled = false;
}
} |
In the above code, we have written a new renderer which is derived from GridCellSwitchRenderer. And then removed the existing switch renderer from the CellRenderers collection and added our own renderer.
We have prepared a simple sample for your reference and you can download the same from the below link.
Please refer the below KB link. In the KB we have written a new renderer HeaderCell in Xamarin.iOS platform(modify the code based on Xamarin.Forms platform). We have attached this KB for your reference and which will help you to understand better.
Regards,
Divakar.