How can you style a DataGridPickerColumn
One of the new features of version 31.x is the DataGridPickerColumn being added to the DataGrid. I have it working in my code without issue but I am wondering how I can style this new Picker?
I have tried a variety of ways but nothing so far has worked (and the Picker still uses the default purple color for highlighting a selected row). I am sure I am just missing something obvious. Can you provide an example of how to style the DataGridPickerColumn like you can a standard Picker control?
Thanks,
TB
public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); // Replace the default Picker cell renderer with your custom renderer dataGrid.CellRenderers.Remove(nameof(Picker)); dataGrid.CellRenderers.Add(nameof(Picker), new CustomDataGridPickerCellRenderer()); } } |
public class CustomDataGridPickerCellRenderer : DataGridPickerCellRenderer { public override void OnInitializeEditView(DataColumnBase dataColumn, SfPicker picker) { base.OnInitializeEditView(dataColumn, picker); // Apply custom styles to the Picker picker.SelectionView = new PickerSelectionView() { CornerRadius = 10, Stroke = Color.FromArgb("#36454F"), Padding = new Thickness(10, 5, 10, 5), Background = Colors.DodgerBlue }; // You can also customize text color, font, etc. picker.HeaderText = "Select an option"; picker.BackgroundColor = Colors.LightGray; } |
- Use dataGrid.CellRenderers.Remove and Add to replace the default renderer.
- Override OnInitializeEditView to access the SfPicker and apply styles.
- You can customize properties like Background, CornerRadius, Stroke, Padding, and even header text or font styles.
Attachment: DataGridPickerColumnSample_4341727f.zip
Thank you SO very much for the code example as I was able to style the DataGridPickerColumn with ease.
The only thing that I haven't been able to figure out is how can you change/specify the text color within the PickerSelectionView? I can change the row's background color but I can't seem to find out how to change the selected text option. I am sure it's something simple that I have just overlooked along the way.
Thanks again for all of the assistance.
Take care,
TB
picker.SelectedTextStyle = new PickerTextStyle() { TextColor = Colors.Red, // Set your desired color here FontSize = 18 // Optional: customize font size }; |
- 3 Replies
- 2 Participants
-
TB Todd Banister
- Dec 9, 2025 05:26 PM UTC
- Dec 15, 2025 11:56 AM UTC