C# .NET: Add Control to a XAML Grid with Row and Column

10/12/2014 10:15:10 PM

In XAML, this code will allow you to add a control to a specific row/grid in a XAML Grid.

Button butHelloWorld = new Button();
butHelloWorld .Content = "HELLO!";

//add other attributes including onclick properties

int row = 1;
int column = 5;

Grid.SetRow(butHelloWorld , row); 
Grid.SetColumn(butHelloWorld , column);
gridMyGrid.Children.Add(butHelloWorld );