dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.41k stars 982 forks source link

Make MenuStrip and ContextMenuStrip look more Windows-native #2476

Open chylex opened 4 years ago

chylex commented 4 years ago

With the removal of MainMenu and ContextMenu native wrappers in .NET Core 3.1, and no alternative for native controls, it'd be a good idea to make the replacement strip controls look and feel more native.

Including screenshots from Windows 10 and 7, and RenderMode set to ManagedRenderMode and System to point out differences.

Windows 10

Native Strip (System) Strip (Managed)
NativeMenu10 StripSystemMenu10 StripManagedMenu10
NativeContext10 StripSystemContext10 StripManagedContext10

Windows 7

Native Strip (System) Strip (Managed)
NativeMenu7 StripSystemMenu7 StripManagedMenu7
NativeContext7 StripSystemContext7 StripManagedContext7

Additional Information

The visual differences should be obvious, but there are a few usability differences as well:

Test Project

The test project targets .NET Core 3.0, and opens 3 windows (native + the 2 strip variations).

WindowsFormsStripControlsCore.zip

merriemcgaw commented 4 years ago

I think we should break this up into a couple of sub-issues:

I'd prefer not to change the way we require the form to get focus before invoking the MenuStrip's command. I'm not 100% sure this scenario, but we believe we should make the form have focus before invoking commands in the form. Concern that doing so would raise a potential accessibility issue

If you find any more issues could you please file separate issues for them and link this one?

chylex commented 4 years ago

Would you like me to break up the current issue into sub-issues, or will you do that and I should only file new ones if I find further differences?

I'd prefer not to change the way we require the form to get focus before invoking the MenuStrip's command.

It's different from how this style of main menus work on Windows. Any app I've tried immediately opens the clicked main menu item even if the window is initially unfocused:

RussKie commented 4 years ago

Would you like me to break up the current issue into sub-issues, or will you do that and I should only file new ones if I find further differences?

If you don't mind, please raise a separate issue for each. The more details you provide - the better.

Any app I've tried immediately opens the clicked main menu item even if the window is initially unfocused:

Please raise this issue as well. In it please explain how to repro, I can't seem to get an unfocused app with an open menu/contextmenu.

Thank you

chylex commented 4 years ago

I will try to file separate issues today or tomorrow with more details.

Please raise this issue as well. In it please explain how to repro, I can't seem to get an unfocused app with an open menu/contextmenu.

Not sure I follow.

The issue is that with MenuStrip in an unfocused window, opening a menu requires 2 clicks - one to focus the window and one to actually open the menu - while MainMenu and basically every app that has a main menu only requires 1 click over the unfocused window to open the menu.

Context menu works as expected with both ContextMenu and ContextMenuStrip, no issue there.

chylex commented 4 years ago

I haven't opeend an issue on ClientHeight yet. I suspected that StatusBar vs StatusStrip would have the same issue, but StatusBar still exists in 3.1 and wasn't mentioned in the removal PR. Any idea what's up with that?

RussKie commented 4 years ago

but StatusBar still exists in 3.1 and wasn't mentioned in the removal PR. Any idea what's up with that?

Thank you for pointing, it was obviously missed in the clean up (we had a tight deadline). It will be removed in the .NET 5.0 timeframe, we will need to consider whether we'll patch 3.1.

xv commented 1 year ago

Having native/OS theming on MenuStrip and ContextMenuStrip would be amazing.

I've been using the now-removed MainMenu for 10+ years just so I can have a unified and consistent UI, and I am now stuck with .NET 4.8 because of how hideous MenuStrip looks. It was ugly in 2007 and it's even more ugly today, especially with its XP-reminiscent drop shadow that you'll instantly notice on Windows 11, and the lack of dropdown fade in animation.

Call MainMenu obsolete or whatever you feel like, but frankly, going from MainMenu to MenuStrip is a visual downgrade -- a bad one.

Please Microsoft 🙏

chylex commented 1 year ago

Since there's been no updates on this, my solution has been to port the removed controls from .NET Core 3.0. I only ported what I needed, which was ContextMenu and only some of its features; it required reflection to access private fields, but it does work: https://github.com/chylex/TweetDuck/tree/master/windows/TweetLib.WinForms.Legacy

It should be possible to port MainMenu, other ContextMenu features, or anything else that was removed, you'll just have to maintain it yourself and thoroughly test it.

modz2014 commented 1 year ago

nothing for windows 11 yet either