Window Size when SizeToContent is not specified

后端 未结 4 1517
借酒劲吻你
借酒劲吻你 2021-01-22 21:23

When the following XAML used, the window size is not 5000x5000, but some small window where the button is cropped.



        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 22:00

    I think the information you're looking for is buried in the documentation for FrameworkElement.Width (link).

    In addition to acceptable Double values, this property can also be Double.NaN. This is how you specify auto sizing behavior. In XAML you set the value to the string "Auto" (case insensitive) to enable the auto sizing behavior. Auto sizing behavior implies that the element will fill the width available to it. Note however that specific controls frequently supply default values in their default styles that will disable the auto sizing behavior unless it is specifically re-enabled. [my emphasis]

    So, from this, I would expect that the width/height of the Window when there are no other constraints set (such as MaxWidth, MinWidth, Width, etc.) is determined by the default style of a Window.

    Edit:

    Looks like it's more likely it comes from a function called by the Window class itself that takes into account all the constraints plus the monitor size.

提交回复
热议问题