|
<Button Text="Click To Change Color" Clicked="Button_Clicked"></Button>
<sfgrid:SfDataGrid x:Name="mainDataGrid"
Grid.Row="1"
AutoGenerateColumns="False"
ColumnSizer="Star"
ItemsSource="{Binding OrdersInfo}"
>
<sfgrid:SfDataGrid.Columns>
<sfgrid:GridTextColumn HeaderText="Column 2" Width="100" MappingName="OrderID"></sfgrid:GridTextColumn>
<sfgrid:GridTextColumn Width="200" MappingName="EmployeeID"></sfgrid:GridTextColumn>
<sfgrid:GridTemplateColumn Width="50" MappingName="EmployeeID">
<sfgrid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Text="{Binding EmployeeID}" FontFamily="fontawesome-webfont">
</Label>
</DataTemplate>
</sfgrid:GridTemplateColumn.CellTemplate>
</sfgrid:GridTemplateColumn>
</sfgrid:SfDataGrid.Columns>
</sfgrid:SfDataGrid>
… DataRowBase rowdata; VirtualizingCellsControl wholeRowElement;
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
var model = (GridModel)mainDataGrid.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("GridModel")).GetValue(mainDataGrid);
rowdata = SfDataGridHelpers.GetRowGenerator(mainDataGrid).Items.FirstOrDefault(x => x.RowIndex == 2);
if (rowdata != null)
{
wholeRowElement = (VirtualizingCellsControl)rowdata.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name.Equals("WholeRowElement")).GetValue(rowdata);
wholeRowElement.BackgroundColor = Xamarin.Forms.Color.Red;
}
} |