WPF UserControl Designer Problem with Strech

visual-studio-2008wpf

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?

Best Answer

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