Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JamestsaiTW/a07de6cc6d34f392481f43c6ffcb6c01 to your computer and use it in GitHub Desktop.
Save JamestsaiTW/a07de6cc6d34f392481f43c6ffcb6c01 to your computer and use it in GitHub Desktop.
Xamarin.Forms for Grid
private void PreviewGridCell(Grid grid , Color cellBackgroundColor)
{
var columnCount = grid.ColumnDefinitions.Count;
var rowCount = grid.RowDefinitions.Count;
for (int row = 0; row < rowCount; row++)
{
for (int column = 0; column < columnCount; column++)
{
var boxView = new BoxView()
{
BackgroundColor = cellBackgroundColor
};
Grid.SetColumn(boxView, column);
Grid.SetRow(boxView, row);
grid.Children.Add(boxView);
}
}
var allBuildPreviewCellCount = columnCount * rowCount;
for (int start = 0; start < grid.Children.Count- allBuildPreviewCellCount; start++)
{
var targetCellView = grid.Children[0];
for (int raiseCount = 0; raiseCount < grid.Children.Count - 1; raiseCount++)
{
grid.RaiseChild(targetCellView);
}
}
}
========================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment