2015-05-14 100 views
1

我怎樣才能設置窗口的MaxHeight屬性到屏幕高度?WPF: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"> 
+0

你是什麼屏幕意思?它是你的顯示器嗎?如果你不定義任何MaxHeight,那麼這意味着沒有MaxHeight? – Krishna

+0

@克里希納是的,我的意思是我的顯示器。如果我不定義MaxHeight窗口增長的屏幕尺寸(高度) – sanjar14

+0

請看我的答案 – Krishna

回答

3

在你的控制代碼隱藏頁面您可以在窗口的MaxHeight設置爲

System.Windows.SystemParameters.PrimaryScreenHeight 

,或者您可以使用SystemParameters.VirtualScreenHeight