cefsharp / cefsharp/CefSharp

Feature Request - Ability to set WPF context menu's style

Open
#5,242 1 comment 0 reactions 0 assignees View on GitHub
feature-request up-for-grabs
Dominant language
C#
Stars
10.3k
Forks
2.9k
Avg merge
5d 22h
Merged PRs (30d)
4

Description

**Describe the solution you'd like**
I moved from `IContextMenuHandler` to `CefSharp.Wpf.Handler.ContextMenuHandler` in order to avoid #1882.

As a result, the context menu now has the default WPF styling, which doesn't really fit Chrome or modern Windows.

I would like to be able to set the context menu's `Style` property; however, the context menu is instantiated ad-hoc, so this doesn't seem possible. I.e., I would like

- either a property `ContextMenuStyle` on `CefSharp.Wpf.ChromiumWebBrowser` to set the style beforehand, then if set, have `CefSharp.Wpf.Handler.ContextMenuHandler` apply it
- or an event `ContextMenuCreated` in `CefSharp.Wpf.Handler.ContextMenuHandler` which I can listen to

**Describe alternatives you've considered**
- implementing `IContextMenuHandler` myself (or inheriting from `CefSharp.Wpf.Handler.ContextMenuHandler`. However, that seems like a lot of error-prone work.
- using `CefSharp.Wpf.Handler.ContextMenuHandler` but overriding `RunContextMenu` to grab the created `ContextMenu`. This doesn't (seem to) work reliably due to timing issues.

**Checklist:**
- [x] I have reviewed the [CEF API](https://magpcss.org/ceforum/apidocs3/index-all.html) and have confirmed the feature I'm requesting is possible.
~~- [ ] The Feature I'm requesting is an improvement to Async Javascript Binding (No new feature are being added to the Sync Javascript binding)~~
~~- [ ] An open `PR` exists on the [CEF Pull Requests](https://bitbucket.org/chromiumembedded/cef/pull-requests/) and I'd like to propose this feature is added to `CefSharp` when/if it's merged.~~

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.