Shiny Controls v1.0 - The Ultra Control Suite for .NET MAUI & BlazorO...M...G!
DataGrid | Conditional Cell Styling
CellStyle takes the row item and returns a DataGridCellStyle for that one cell — red negatives,
an amber overdue cell — or null to keep the themed default. Each member is independently optional.
@* Blazor — colours are CSS, so a theme token works as well as a hex *@<PropertyColumn Property="x => x.Salary" DisplayAs="DataGridColumnFormat.Currency" Decimals="0" CellStyle="@(p => p.Salary < 100000 ? new DataGridCellStyle { TextColor = "var(--shiny-color-error)", Bold = true } : null)" />// MAUI — expose it from the view model and bindpublic Func<object, DataGridCellStyle?> SalaryStyle => item => ((Person)item).Salary < 100000 ? new DataGridCellStyle { TextColor = Colors.Firebrick, FontAttributes = FontAttributes.Bold } : null;<shiny:DataGridColumn Title="Salary" PropertyName="Salary" DisplayAs="Currency" Decimals="0" CellStyle="{Binding SalaryStyle}" />On MAUI TextFormatter, CellStyle and Culture are BindablePropertys so {Binding} from a view
model works; the grid pushes its BindingContext down to its columns for exactly that reason (columns
are BindableObjects, not elements, so they inherit nothing on their own). On Blazor,
DataGridCellStyle.CssClass is not scoped to the grid’s isolated stylesheet — declare that class in
your app’s CSS.
Next Steps
Section titled “Next Steps”- Column Formatting — display presets, alignment, wrapping
- Column Widths — pixels, stars and percentages


