using System; using Windows.UI.Xaml; using Windows.UI.Xaml.Input; // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 namespace OwlCore.WinUI.Controls { /// /// A simple popup/overlay that can display arbitrary content. /// public sealed partial class ContentOverlay { /// /// Creates a new instance of . /// public ContentOverlay() { InitializeComponent(); } /// /// Shows the . /// /// The data to show /// The header text to show. public void Show(FrameworkElement el, string headerText = "") { HeaderText.Text = headerText; Presenter.Content = el; if (Visibility == Visibility.Collapsed) { Visibility = Visibility.Visible; ShowAnimation.Begin(); } } /// /// Hides the . /// /// /// Occurs indirectly. /// Visibility is collapsed and content is removed after animation. /// public void Hide() { HideAnimation.Begin(); } private void CompleteHide() { Visibility = Visibility.Collapsed; Presenter.Content = null; Closed?.Invoke(this, EventArgs.Empty); } /// /// Raised when the content overlay is closed. /// public event EventHandler? Closed; private void CloseButton_OnClick(object sender, RoutedEventArgs e) => Hide(); private void Background_OnTapped(object sender, TappedRoutedEventArgs e) => Hide(); private void HideAnimation_Completed(object sender, object e) => CompleteHide(); } }