I created a grid on my WPF application with 4 rows and columns to display media:
<Grid Name="ControlsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33*" />
<ColumnDefinition Width="33*" />
<ColumnDefinition Width="33*" />
<ColumnDefinition Width="33*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="33*" />
<RowDefinition Height="33*" />
<RowDefinition Height="33*" />
<RowDefinition Height="33*" />
</Grid.RowDefinitions>
</Grid>
And from another method i add to the grid:
WindowsFormsHost formhost = new WindowsFormsHost();
formhost.Child = new System.Windows.Forms.Control();
formhost.Child = control;
ControlsGrid.Children.Add(formhost);
The objects are loading fine, during debug i see the size of collection increases.. but the control is being displayed on the first 0,0 grid and when adding a new control it over ride the control that was there.
How can i set the control on an empty place on the grid ?
You just have to set the
Grid.ColumnandGrid.Rowfor the controls to be in each space.However I noticed you are setting all the Grid Columns/Rows the same size, so perhaps UniformGrid would be a better option
Xaml:
Code: