public Popup Show(PopupSize size, UIElement content = null) { var popup = Create(size, content); popup.IsOpen = true; return(popup); }
public ShowPopupEvent(PopupOptions buttonOptions, string popupTitleKey, string popupContentKey, Action <PopupResult> onResultCallback, bool cancelOnBackgroundClick = false, PopupSize size = PopupSize.W800H600) { ButtonOptions = buttonOptions; PopupTitleKey = popupTitleKey; PopupContentKey = popupContentKey; ResultCallback = onResultCallback; Size = size; CancelOnBackgroundAvailable = cancelOnBackgroundClick; }
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) { if (size == PopupSize.FullScreen) { container.Height = Window.Current.Bounds.Height; container.Width = Window.Current.Bounds.Width; } else if (size == PopupSize.ContentBased) { popup.HorizontalOffset = (Window.Current.Bounds.Width - popup.ActualWidth) / 2; popup.VerticalOffset = (Window.Current.Bounds.Height - popup.ActualHeight) / 2; } } }; popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) => { if (popup.IsOpen) { Window.Current.SizeChanged += handler; } else { Window.Current.SizeChanged -= handler; } }); popup.Loaded += (s, e) => handler.Invoke(null, null); return(popup); }
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; }
public Popup Show(PopupSize size, UIElement content = null) { var popup = Create(size, content); popup.IsOpen = true; return popup; }
public Popup Show(PopupSize size, UIElement content = null) { var popup = Create(size, content); return(Show(popup)); }