0
votes

I have a WPF UserControl (Foo.xaml) that should be displayed streched (VerticalAlignment="Stretch" HorizontalAlignment="Stretch") on a window.

  • If I don't specify Width/Height on the UserControl it will be displayed as intended at runtime. Unfortunately the VS WPF designer will not show the control correctly if I open Foo.xaml (size may be 0x0 depending on the child controls).

  • If I specify a size on the UserControl the designer will work correctly with Foo.xaml but then it won't strech at runtime.

How can I fix this so that it works at design and runtime?

2

2 Answers

1
votes

It sounds like your UserControl is only useful if it is a certain minimum size. If so, set the MinWidth and MinHeight properties.

0
votes

You can set the DesignWidth and DesignHeight properties on the UserControl to adjust the height and width of the control in the design view.

You can adjust those properties with the mouse by dragging the square rectangles that show up when you select the resize tool for the UserControl.