WPF UserControl Design Time Size

后端 未结 9 857
[愿得一人]
[愿得一人] 2020-11-30 22:36

When creating a UserControl in WPF, I find it convenient to give it some arbitrary Height and Width values so that I can view my changes in the Visual Studio designer. When

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 22:55

    I do this all the time. Simply set the width and height values to "auto" where you instantiate your control, and this will override the design-time values for that UserControl.

    ie:

    Another option is to set a combination of MinWidth and MinHeight to a size that allows design-time work, while Width and Height remain "auto". Obviously, this only works if you don't need the UserControl to size smaller than the min values at runtime.

提交回复
热议问题