For some reason, I need to get the device screen height in the page constructor and use it to set the sizes of other page items. I do it like this:
double screenHeight = Application.Current.RootVisual.RenderSize.Height;
However, I've recently detected that this code fails if the app comes out of tombstoning and this page is the active page. In this case, Application.Current.RootVisual
is null.
How to overcome this, or are there other methods to get the screen height?
Actually, Application.Current.RootVisual.RenderSize
returns screen resolution. If that is what you want, use Application.Current.Host.Content.ActualHeight
instead:
double screenHeight = Application.Current.Host.Content.ActualHeight;