tania
tania

Reputation: 1

WPF set UserControl size to MainWindow container size

I have a mainWindow that has a menu and container to place a userControl depending on menu button click. dpmain in a StackPanel in a Grid, Width and Height is Auto, Horisontal and Vertical Alignments are Stretch everywhere in my application

dpMain.Children.Clear();
dpMain.Children.Add(element);

UserControl is a big datagrid, when I add Userconrol to mainform, mainform resizing to the size of the grid, but I actually need the grid be the size of Actual size of the StackPanel, and be able to resize when I resize the Main form.

Thank you

Upvotes: 0

Views: 1049

Answers (1)

brunnerh
brunnerh

Reputation: 184516

A StackPanel is not a suitable panel for this as it only allows stretching in one direction. If you have just one control try to replace the whole panel with it.

Upvotes: 0

Related Questions