Why are my WPF window sizes defaulting to be huge

后端 未结 3 1146
清酒与你
清酒与你 2020-12-20 11:16

I have a wpf application with a few forms. At design time they are small, and they are not set to auto size. However at run time they are giant, even with no content in them

3条回答
  •  眼角桃花
    2020-12-20 11:51

    If you create a with this code:

    
    

    Then when you run that from Visual Studio it will display a window the same size as the one you put in your question. So this isn't anything you explicitly did.

    What you've encountered is the default computed size of a WPF Window. For different results, specify a SizeToContent parameter on the Window, as paxdiablo pointed out, or explicitly set the size of your window with the MinHeight, MaxHeight, Height, MinWidth, MaxWidth, and/or Width properties.

提交回复
热议问题