Radoslaw
Radoslaw

Reputation: 243

How to get screen size in Panorama control of Windows Phone 7

How to programatically get an actual screen size (width and height) in Windows Phone? Normally I would use the following: How to get screen size on Windows Phone 7 Series

But Panorama control is a bit tricky, since the above code gives a PanoramaItem width and height (not Panorama width and height).

I have the following code that creates popup:

 modalPopup = new Popup();
 modalPopup.Child = new ModalWait() { MaxWidth = Application.Current.Host.Content.ActualWidth };
 modalPopup.IsOpen = true;

As I result a popup is created a width of PanoramaItem, which is not a total width of a phone screen. There's a right margin which is not covered with the popup. See the screenshot below:

wp screensize problem

Any ideas how to overcome this right margin and get the actual phone screen size?

Upvotes: 0

Views: 321

Answers (1)

Alaa Masoud
Alaa Masoud

Reputation: 7135

The MaxWidth property does not set an element's width. It gets/sets the maximum width constraint of that element. You want to use the Width property instead.

The code you showed Application.Current.Host.Content.ActualWidth will give you the correct screen width, not just the panorama item's width.

Upvotes: 1

Related Questions