Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get window size

Tags:

c#

windows

xaml

uwp

I'm writing a Windows Universal app, and need a way to get the window's height. I have found the Window.Bound, but the Bound variable is non-static. Therefore, I would need to know the default Window object that is created, that is, if it exists and is public.

If I cannot access this, what is another way that I can get the window's height?

like image 211
MattyAB Avatar asked Nov 12 '16 17:11

MattyAB


1 Answers

You can access the corresponding Window using Window.Current and there you can get the size. You can also try accessing the rootFrame and getting the size from it:

((Frame)Window.Current.Content).ActualHeight

and

((Frame)Window.Current.Content).ActualWidth
like image 168
Marian Dolinský Avatar answered Oct 01 '22 01:10

Marian Dolinský