i use a grid, that’s content will often be changed.
in xaml it just looks like this:
<Grid Name="grid1"/>
In C# I do this:
private void informGrid()
{
grid1= new Grid();
grid1.Background = new SolidColorBrush(Colors.Transparent);
grid1.Visibility = Visibility.Visible;
Canvas.SetZIndex(grid1, 51);
grid1.SetValue(Grid.RowProperty, 1);
grid1.Margin = new Thickness(0, 0, 0, 0);
grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(hw) });
grid1.RowDefinitions.Add(new RowDefinition { Height = new GridLength(hw) });
grid1.ColumnDefinitions.Add(new ColumnDefinition{ Width=new GridLength(hw)});
grid1.ColumnDefinitions.Add(new ColumnDefinition{ Width=new GridLength(hw)});
grid1.ColumnDefinitions.Add(new ColumnDefinition{ Width=new GridLength(hw)});
grid1.ColumnDefinitions.Add(new ColumnDefinition{ Width=new GridLength(hw)});
grid1.ColumnDefinitions.Add(new ColumnDefinition{ Width=new GridLength(hw)});
fillGrid();
}
And then I add 10 images into this grid, in each cell 1 (100% working).
the grid becomes visible, has the right row&columndefinitons, 10 children, but the pictures aren’t there.
i bet theres just a small mistake, but i wasn’t able to find it.
please help me.
thanks.
used stackpanels instead, worked fine and you just have to clear the content