AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.79k stars 2.23k forks source link

Open/close menu events are confusing #4443

Open grokys opened 4 years ago

grokys commented 4 years ago

The following events are available on Menu/ContextMenu:

I see a few issues here:

  1. The MenuOpened event is inherited by ContextMenu meaning that its open event has the Menu prefix but its opening event has the ContextMenu prefix
  2. Why is a cancelable Closing event needed? I've never seen a context menu that can't be closed, and having one sounds like a problem
  3. Why are the context menu events not routed events?
  4. There should probably be an Opening event on Menu too (though it shouldn't be cancelable)

I suggest the following;

@WojciechKrysiak you implemented ContextMenuOpening/Closing - what do you think?

WojciechKrysiak commented 4 years ago

I have no preference either way - the only reason I implemented it like that was to mirror WPF naming and behavior, as you can mark the event as handled through its args. This has the same effect as cancelling it.

As for why it wasn't done as a routed event - I can't remember, but most likely lack of skill back then.

I agree that unifying the naming is a good aim, but it would introduce additional work for people porting from WPF.

maxkatz6 commented 5 months ago

Also, ToolTip events https://github.com/AvaloniaUI/Avalonia/pull/15493