5

I am creating a Notepad like application in WPF. I want to set the window form height and width according to screen size . How can i get Screen height and width ?

Durga Dutt
  • 4,093
  • 11
  • 33
  • 48

2 Answers2

13

Just bind SystemParameters properties to your window properties.

<Window x:Class="YourWindow"
    Height="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}" 
    Width="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width}">
kyrylomyr
  • 12,192
  • 8
  • 52
  • 79
  • 2
    SystemParameters offers resource keys for all its properties. It is better to use DynamicResource instead of bindings. – Marat Khasanov Mar 13 '11 at 20:47
  • This is not working here. "SystemParameters is not supported in a Windows Presentation Foundation (WPF) Project." A shame :| – Malavos Feb 10 '14 at 11:56
8

See System.Windows.SystemParameters

You have properties like

  • PrimaryScreenWidth
  • PrimaryScreenHeight
  • VirtualScreenHeight
  • VirtualScreenWidth
  • WorkArea

etc.

This question might help as well: How can I get the active screen dimensions?

Community
  • 1
  • 1
Fredrik Hedblad
  • 83,499
  • 23
  • 264
  • 266