Durga Dutt
Durga Dutt

Reputation: 4113

WPF window size

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 ?

Upvotes: 5

Views: 21765

Answers (2)

kyrylomyr
kyrylomyr

Reputation: 12652

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

Upvotes: 13

Fredrik Hedblad
Fredrik Hedblad

Reputation: 84684

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?

Upvotes: 8

Related Questions