4

How do I make a Popup take up the full width and height of the screen? I don't want to set explicit height and width of 480x800.

Josh Close
  • 22,935
  • 13
  • 92
  • 140

2 Answers2

7

I use this function:

public static Size GetScreenSize()
{
  return Application.Current.RootVisual.RenderSize;
}

As Derek points out, you need to handle rotation, etc, yourself.

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • Thanks for answering the actual question even though I went a different route. It's still good to know. – Josh Close Mar 18 '11 at 16:06
  • @jeffamaphone could you add a working example, because the popup size seems constant, for what I am doing? – JTIM Jan 30 '15 at 10:33
  • Sorry man. That was four years ago and I'm not doing Windows Phone development at the moment, so I'd have to go figure it out all over again. Good luck though! – i_am_jorf Jan 30 '15 at 16:52
5

Popup has quite poor performance on WP7, doesn't support rotation and is difficult to size, so to implement a full screen popup you'd be better off using a Grid, which by default will fill the page if you put it at the root of the Page.

Derek Lakin
  • 16,179
  • 36
  • 51
  • I'm doing the `Popup` for a login screen on the start of the application. Do you think it would be preferable to show a `Grid` instead of the `Panorama`, and just switch out the `Grid` if they don't need to login or after login (so it's not on the back stack)? – Josh Close Mar 17 '11 at 16:44
  • Peter Torr says to use a popup, which is why I was going that route. http://blogs.msdn.com/b/ptorr/archive/2010/08/01/exiting-a-windows-phone-application.aspx – Josh Close Mar 17 '11 at 16:54
  • Peter Torr is an incredibly talented guy and yes he's right that you should use a some form of popup instead of doing conditional navigation, etc for Login pages, etc, but the implementation of that is better using a `Grid` instead of the actual `Popup` control for the reasons I described. – Derek Lakin Mar 17 '11 at 16:58
  • Great. What is the preferred method for showing the popup if I'm using a `Grid` instead? Just have the popup `Grid` showing and my `Panorama` collapsed until they login, then collapse the `Grid` and make the `Panorama` visible? Or is there a better way to switch them out? – Josh Close Mar 17 '11 at 17:11
  • If the `Grid` is full screen, there's no need to toggle the visibility of the `Panorama`, just the `Grid`. I tend to find that visual states are a good way of handling it, which also enables you to do animated transitions, too. – Derek Lakin Mar 17 '11 at 19:58