windows phone 8 popup width and height

后端 未结 1 1967
萌比男神i
萌比男神i 2021-01-20 15:33

I am placing a grid in a popup control. I expected the grid to be re-sized automatically according to the 3 different layout sizes for windows phone 8 apps (480 × 80

1条回答
  •  心在旅途
    2021-01-20 16:02

    The easiest way to get a full screen popup to work on WP8 is by setting the Child width & height to the phone's current logical resolution. You can read more about WP8 Multi-resolution zen here and learn more about WP8 Multi-resolution APIs here.

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        var myPopup = new Popup()
        {
            Child = new Border()
            {
                Child = new TextBlock()
                        {
                            Text = "Hello World!"
                        },
                Height =  Application.Current.Host.Content.ActualHeight,
                Width =  Application.Current.Host.Content.ActualWidth,
                Background = new SolidColorBrush(Colors.Green)
            }
        };
    
        this.LayoutRoot.Children.Add(myPopup);
        myPopup.IsOpen = true; 
    }
    

    This code snippet is a bit overzealous since shell items (e.g. SystemTray, AplicaitonBar, etc) can take space away from your rendering area.

    Here's a print screen of the code snippet above executing in the WXGA emulator:

    Full screen popup on WXGA

    And here's the code snippet above executing in the 720P emulator: Full screen popup on 720P

    0 讨论(0)
提交回复
热议问题