Hello Bill,
You can accomplish this by using the
CellDecorationStyleSelector property of the DataGrid Column(s).
DemoHere's is the result of the approach at runtime, the yellow style is when the item is on sale and the red style is when it's out of stock:
CodeView:
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
ContentPage
...>
<
ContentPage.BindingContext
>
<
local:ViewModel
/>
</
ContentPage.BindingContext
>
<
ContentPage.Resources
>
<
ResourceDictionary
>
<
local:MyCellDecorationStyleSelector
x:Key
=
"MyStyleSelector"
>
<
local:MyCellDecorationStyleSelector.NormalStyle
>
<
dataGrid:DataGridBorderStyle
BackgroundColor
=
"White"
BorderColor
=
"Transparent"
BorderThickness
=
"0"
/>
</
local:MyCellDecorationStyleSelector.NormalStyle
>
<
local:MyCellDecorationStyleSelector.OnSaleStyle
>
<
dataGrid:DataGridBorderStyle
BackgroundColor
=
"LightGoldenrodYellow"
BorderColor
=
"Yellow"
BorderThickness
=
"2"
/>
</
local:MyCellDecorationStyleSelector.OnSaleStyle
>
<
local:MyCellDecorationStyleSelector.OutOfStockStyle
>
<
dataGrid:DataGridBorderStyle
BackgroundColor
=
"Red"
BorderColor
=
"DarkRed"
BorderThickness
=
"2"
/>
</
local:MyCellDecorationStyleSelector.OutOfStockStyle
>
</
local:MyCellDecorationStyleSelector
>
</
ResourceDictionary
>
</
ContentPage.Resources
>
<
dataGrid:RadDataGrid
x:Name
=
"DataGrid"
ItemsSource
=
"{Binding Products}"
AutoGenerateColumns
=
"False"
>
<
dataGrid:RadDataGrid.Columns
>
<
dataGrid:DataGridTextColumn
PropertyName
=
"Title"
CellDecorationStyleSelector
=
"{StaticResource MyStyleSelector}"
/>
<
dataGrid:DataGridNumericalColumn
PropertyName
=
"Price"
CellDecorationStyleSelector
=
"{StaticResource MyStyleSelector}"
/>
</
dataGrid:RadDataGrid.Columns
>
</
dataGrid:RadDataGrid
>
</
ContentPage
>
Data model:
View model
and finally the selector class:
Wrapping UpYou can see more in the DataGrid "Customization Example" demo. You can browse the code on GitHub
here or if you've installed UI for Xamarin to the default location, you'll find the demo at the following location:
C:\Program Files (x86)\Progress\Telerik UI for Xamarin R1 2018\QSF\QSF\Examples\DataGridControl\CustomizationExample I hope I was able answer your question, if I have be sure to mark the post as such so that other visitors looking for the same thing can easily find it.
Let me know if you have any additional questions.
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items