views:

427

answers:

3

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?

+1  A: 

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

HTH, Kent

Kent Boogaart
+2  A: 

I found a similar question (and answers) elsewhere on SO.

Daniel Pratt
A: 

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.

sipwiz
Afaik that only works in Blend, not VS.
Joey
OK, that's why I couldn't find those properties!
chris