Grial-UI-Kit-Support
Grial-UI-Kit-Support copied to clipboard
Bind background color of DataGrid's Row Using Grial UI kit in Xamarin
Hello @jpbrocca
I am using Grial Kit UI in xamarin and implement a DataGrid Page, But i want to bind background color of each row in Grid data.
This is my UI Code
<!-- Grid Styles -->
<Style TargetType="grial:DataGrid">
<Setter Property="SelectedBackgroundColor" Value="#20BFE1FF" />
<Setter Property="HeaderRowBackgroundColor" Value="{ DynamicResource DataGridHeaderRowBackgroundColor }" />
<Setter Property="BackgroundColor" Value="{ DynamicResource DataGridBackgroundColor }" />
<Setter Property="GridSeparatorVisibility" Value="None" />
<Setter Property="HeaderSeparatorVisibility" Value="None" />
</Style>
<!-- Column Styles -->
<Style x:Key="BaseColumn" TargetType="grial:DataGridColumn">
<Setter Property="IsSortable" Value="True" />
<Setter Property="SortIconsFontFamily" Value="{StaticResource IconsFontFamily}" />
<Setter Property="ColumnWidth" Value="0.1*" />
<Setter Property="HeaderTextColor" Value="{ DynamicResource DataGridHeaderTextColor }" />
<Setter Property="HeaderTextAlignment" Value="Center" />
<Setter Property="HeaderFontSize" Value="14" />
<Setter Property="HeaderFontFamily" Value="{ StaticResource AppBoldFontFamily }" />
<Setter Property="CellTextColor" Value="{ DynamicResource DataGridCellTextColor }" />
<Setter Property="CellPadding" Value="14" />
<Setter Property="CellFontSize" Value="14" />
<Setter Property="CellTextAlignment" Value="Center" />
<Setter Property="CellVerticalAlignment" Value="Center" />
<Setter Property="HeaderPadding" Value="4,14" />
</Style>
<Style x:Key="NC_Audit_Column" TargetType="grial:DataGridColumn" BasedOn="{StaticResource BaseColumn}">
<Setter Property="BindingPath" Value="NON_COMPLY_AUDIT" />
<Setter Property="HeaderText" Value="AUDIT" />
</Style>
<Style x:Key="NC_Score_Column" TargetType="grial:DataGridColumn" BasedOn="{StaticResource BaseColumn}">
<Setter Property="ColumnWidth" Value="75" />
<Setter Property="BindingPath" Value="NON_COMPLY_SCORE" />
<Setter Property="HeaderText" Value="SCORE" />
</Style>
<grial:DataGrid SelectionMode="Row" ItemsSource="{ Binding ItemList}">
<grial:DataGrid.ColumnDefinitions>
<grial:DataGridColumn Style="{ StaticResource NC_Name_Column}" />
<grial:DataGridColumn Style="{ StaticResource NC_Score_Column}" />
</grial:DataGrid.ColumnDefinitions>
</grial:DataGrid>
How can bind background Color in each row and i am passing color field in model
public string Row_BgColor {get; set;}
Thanks
Hi @deepakyogi1995,
That scenario is not supported.
As a workaround, what you could do is to define a template for all the cells, then, you could bind the BackgroundColor
of the cells to your view model.
Regards, JP