GRID XAMARIN code example

Example 1: xamarin froms grid view

<Grid> 
<Grid.RowDefinations>
<RowDefination Height = "Auto"/>
<RowDefination Height = "Auto"/>
<Grid.RowDefinations>

<Grid.ColumnDefinations>
<ColumnDefination Width = "Auto"/>
<ColumnDefination Width = "Auto"/>
<Grid.ColumnDefinations>

<Label Grid.Row ="0"
       Grid.Column ="0"//>
<Label Grid.Row ="0"
       Grid.Column ="1"/>
<Label Grid.Row ="0"/>
<Grid>

Example 2: xamarin forms find the grid.row property of an element

var button = (Button)sender;
var row = Grid.GetRow(button);
var grid = button.Parent as Grid;
//assuming the image is in column 1
var image = grid.Children.Where(c => Grid.GetRow(c) == row && Grid.GetColumn(c)==1);

Tags:

Misc Example