WPF:MaxHeight到屏幕高度

san*_*r14 2 wpf height screen

如何将窗口的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">
Run Code Online (Sandbox Code Playgroud)

Kri*_*hna 7

在控件的代码隐藏页面中,您可以将MaxHeight窗口设置为

System.Windows.SystemParameters.PrimaryScreenHeight
Run Code Online (Sandbox Code Playgroud)

或者你可以使用 SystemParameters.VirtualScreenHeight