Example #1
0
 public Popup Create(PopupSize size, UIElement content = null)
 {
     var container = new ContentControl
     {
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         VerticalContentAlignment = VerticalAlignment.Stretch,
         Height = Window.Current.Bounds.Height,
         Width = Window.Current.Bounds.Width,
         Content = content,
     };
     var popup = new Popup
     {
         Child = container,
         HorizontalOffset = 0,
         VerticalOffset = 0,
     };
     WindowSizeChangedEventHandler handler = (s, e) =>
     {
         if (popup.IsOpen)
         {
             container.Height = e.Size.Height;
             container.Width = e.Size.Width;
         }
     };
     if (size == PopupSize.FullScreen)
     {
         popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) =>
         {
             if (popup.IsOpen)
             {
                 Window.Current.SizeChanged += handler;
             }
             else
             {
                 Window.Current.SizeChanged -= handler;
             }
         });
     }
     return popup;
 }