当使用以下XAML时,窗口大小不是5000x5000,而是一些小窗口,其中裁剪了按钮。
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" >
<Button Width="5000" Height="5000">XXX</Button>
</Window>
据我所知,大小我没有指定SizeToContent属性,默认值为“Manual”,因此它将使用*size of a window is determined by other properties, including Width, Height, MaxWidth, MaxHeight, MinWidth, and MinHeight. *从WPF Windows Overview来看,其他属性似乎是FrameworkElement::MinHeight/Width和FrameworkElement::MaxHeight。但是由于Mins的默认值为0,Maxs为Infinity,而Width/Height为Nan...。这是怎么回事? WPF在哪里获取窗口大小?
任何指向正确方向的指针将不胜感激。
最佳答案
如果未指定宽度和高度,则WPF会使用主屏幕宽度的60%(实际显示窗口的位置)和其高度的60%。这是由所有Windows最终注册自己的Application单例完成的。
关于.net - 未指定SizeToContent时的窗口大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1437099/