private void CommentRepliesBlock_OnCloseButtonTapped(object?sender, TappedRoutedEventArgs e) { if (_commentRepliesPopup is not null) { PopupManager.ClosePopup(_commentRepliesPopup); } }
private static void ClosePopupHotKey(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is IAppPopupContent content) { if (e.NewValue is VirtualKey) { content.UIContent.KeyDown += UIContentOnKeyDown; } else { content.UIContent.KeyDown -= UIContentOnKeyDown; } void UIContentOnKeyDown(object sender, KeyRoutedEventArgs args) { if (args.Key == (VirtualKey)e.NewValue) { PopupManager.ClosePopup(content.UniqueId); } } } }
public AppPopup( IAppPopupContent content, double width = double.NaN, double height = double.NaN, double widthMargin = double.NaN, double heightMargin = double.NaN, double minWidth = 0, double maxWidth = double.MaxValue, double minHeight = 0, double maxHeight = double.MaxValue, bool lightDismiss = false, bool useAnimation = true, Action <IAppPopupContent>?opening = null, Action <IAppPopupContent, object?>?closing = null) { _content = content; _width = width; _height = height; _opening = opening; _closing = closing; _maxWidth = maxWidth; _widthMargin = widthMargin; _heightMargin = heightMargin; _minWidth = minWidth; _maxWidth = maxWidth; _minHeight = minHeight; _maxHeight = maxHeight; _useAnimation = useAnimation; var(windowWidth, windowHeight) = App.AppViewModel.GetAppWindowSizeTuple(); UniqueId = content.UniqueId; content.UIContent.HorizontalAlignment = HorizontalAlignment.Stretch; content.UIContent.VerticalAlignment = VerticalAlignment.Stretch; var themeShadow = new ThemeShadow(); var shadowReceiver = new Grid { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = (Brush)Application.Current.Resources["ApplicationPageBackgroundThemeBrush"], Opacity = 0.4 }; var popupContentPresenter = new ContentPresenter { Shadow = themeShadow, Translation = new Vector3(0, 0, 40), BorderBrush = (Brush)Application.Current.Resources["PixevalBorderBrush"], Background = (Brush)Application.Current.Resources["PixevalPanelBackgroundThemeBrush"], BorderThickness = new Thickness(0.3), CornerRadius = new CornerRadius(10), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Content = content }; themeShadow.Receivers.Add(shadowReceiver); if (lightDismiss) { shadowReceiver.Tapped += OnShadowReceiverOnTapped; } else { shadowReceiver.Tapped -= OnShadowReceiverOnTapped; } void OnShadowReceiverOnTapped(object sender, TappedRoutedEventArgs a) { PopupManager.ClosePopup(PopupManager.OpenPopups[UniqueId]); } Popup = new Popup { RequestedTheme = App.AppViewModel.AppRootFrameTheme, Transitions = new TransitionCollection { new PopupThemeTransition() }, XamlRoot = App.AppViewModel.AppWindowRootFrame.XamlRoot, Width = windowWidth, Height = windowHeight, Child = new Grid { Children = { shadowReceiver, popupContentPresenter } } }; App.AppViewModel.Window.SizeChanged += WindowOnSizeChanged; }