public void MenuAttached(object sender, VisualTreeAttachmentEventArgs e) { if (NativeMenu.GetIsNativeMenuExported(this) && sender is Menu mainMenu) { mainMenu.IsVisible = false; } }
protected override void OnAttached() { base.OnAttached(); Observable.FromEventPattern(AssociatedObject, nameof(AssociatedObject.AttachedToVisualTree)) .Take(1) .Subscribe(x => { if (AssociatedObject.GetVisualRoot() is TopLevel tl) { if (NativeMenu.GetIsNativeMenuExported(tl)) { AssociatedObject.IsVisible = false; } } }); }