WPF窗口大小

时间:2011-03-13 14:09:56

标签: wpf

我正在WPF中创建一个类似于应用程序的记事本。我想根据屏幕尺寸设置窗口高度和宽度。如何获得屏幕高度和宽度?

2 个答案:

答案 0 :(得分:8)

请参阅System.Windows.SystemParameters

你有像

这样的属性
  • PrimaryScreenWidth
  • PrimaryScreenHeight
  • VirtualScreenHeight
  • VirtualScreenWidth
  • WorkArea

这个问题也许有帮助:How can I get the active screen dimensions?

答案 1 :(得分:8)

只需将SystemParameters属性绑定到您的窗口属性即可。

<Window x:Class="YourWindow"
    Height="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}" 
    Width="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width}">
相关问题