I have the following grid in my WPF \"Window\" (yes the class Window);
The Grid.Row and Grid.Column properties are Attached Properties, and as such are not set like normal .net properties. The right way to set them from code is:
Grid.SetRow(someLabel, 0);
Grid.SetColumn(someLabel, 0);
You should be able to do this before or after adding them to the Grid object's Children collection, but setting them before adding the control should prevent any possible flickering.
<yourGrid>
) and the Row Definitions like you have done.Create The Control (<yourcontrol>
). Then Set The ColumnSpan and Row for the Grid:
Grid.SetColumnSpan(<yourControl>, 3);
Grid.SetRow(<yourControl>, 0);
Then add your control to the grid you have created
<yourGrid>.Children.Add(<yourControl>);