How to obtain screen size from xaml?

前端 未结 3 765
独厮守ぢ
独厮守ぢ 2020-12-19 03:14

I\'m using wpf on C# to design GUI, and I want to get screen size (The value of Width and Height) from xaml code.

I knew how to get them from C# code as



        
3条回答
  •  被撕碎了的回忆
    2020-12-19 03:56

    Say your parent container in the XAML is grid, name it as grdForm

    In the code behind can get the dimensions as

    double width=grdForm.ActualWidth

    double height=grdForm.ActualHeight

提交回复
热议问题