How can I dynamically add a button to a grid and specify the row and column position. Right now when I use the following code, it always adds the button to the first row and column.
Button btn2 = new Button();
btn2.Content = "Welcome 600";
SecondGrid.Children.Add(btn2);
In XAML , we do have the option to specify like : <Button Grid.Column="2">Welcome</Button>. How can do the same at runtime.
Thanks
Vishal
Hi Vishal,
You are missing the following two statements ....
Grid
.SetColumn(btn2, 2);
Grid.SetRow(btn2,5);
the second parameter is the respective column or row
after this you can add it to the grid like you have already done.
Cheers,
Tarun
Developer