5
votes

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 ?

2
True. Shouldn't assume SO to be an auto-answer-machine that saves on searching the net.Stephen Chung
If you want the window to fit the screen size, why not just maximize it?Kent Boogaart
Google redirected me to here as the first choice ;-)Dabblernl

2 Answers

11
votes

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}">
8
votes

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?