diff --git a/src/Wpf.Ui.Violeta/Controls/Flyout/FlyoutService.cs b/src/Wpf.Ui.Violeta/Controls/Flyout/FlyoutService.cs index 2784287..c7d4d72 100644 --- a/src/Wpf.Ui.Violeta/Controls/Flyout/FlyoutService.cs +++ b/src/Wpf.Ui.Violeta/Controls/Flyout/FlyoutService.cs @@ -119,6 +119,18 @@ public static void ShowFlyout(FrameworkElement buttonExpected) } } + public static void HideFlyout(FrameworkElement buttonExpected) + { + if (GetFlyout(buttonExpected) is Flyout flyout) + { + if (flyout.GetTemplateChild("PART_Popup") is System.Windows.Controls.Primitives.Popup popup) + { + // Spoof the flyout opening state. + flyout.IsOpen = popup.IsOpen = false; + } + } + } + private static DependencyObject? GetTemplateChild(this FrameworkElement self, string childName) { MethodInfo? method = typeof(FrameworkElement)