How to determine the screen width/height using C#

前端 未结 6 529
再見小時候
再見小時候 2021-02-03 23:48

I want to set the width & height of a Window dynamically based on the user screens maximum width/height. How can I determine this programmatically?

6条回答
  •  执笔经年
    2021-02-04 00:38

    For the primary screen:

    System.Windows.SystemParameters.PrimaryScreenWidth
    System.Windows.SystemParameters.PrimaryScreenHeight
    

    (Note that there are also some other primary screen related properties which depend on various factors, Full* & Maximised*)

    Virtual screen:

    SystemParameters.VirtualScreenWidth
    SystemParameters.VirtualScreenHeight
    

提交回复
热议问题