WPF:将MaxHeight设置为屏幕高度

3

如何将窗口的 MaxHeight 属性设置为屏幕高度?

XAML:

<Window x:Class="RT.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="{Binding WindowTitle}" Height="300" MaxHeight="500" Width="495.149" SizeToContent="WidthAndHeight">

屏幕是什么意思?是指你的显示器吗?如果你没有定义任何最大高度(MaxHeight),那就意味着没有最大高度,对吗? - Krishna
1
@Krishna 是的,我指的是我的显示器。如果我不定义 MaxHeight,窗口就会超出屏幕大小(高度)。 - sanjar14
请查看我的答案。 - Krishna
1个回答

12
在您控件的代码后台页面中,您可以将您的窗口的MaxHeight设置为。
System.Windows.SystemParameters.PrimaryScreenHeight

或者您可以使用 SystemParameters.VirtualScreenHeight


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接