CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

Does the Framework Context menu not work in version 63 of WPF in the xaml of CefSharp.Wpf.Example/Views/BrowserTabView.xaml

Open djangojazz opened this issue 8 years ago • 6 comments

I was curious as I made a clone of the solution but I am seeing all invocation of the context menu is done in code behind with implementing the 'IContextMenuHandler'. Is there any way to invoke the Context Menu directly in the XAML like:

<cefSharp:ChromiumWebBrowser x:Name="browser" Address="http://www.google.com"> <FrameworkElement.ContextMenu> < ContextMenu > < MenuItem Header="Run It" Command="{Binding CommandRun}" / > < /ContextMenu > </FrameworkElement.ContextMenu> </cefSharp:ChromiumWebBrowser> ?

I was curious as in the code example it is all commented out and I may have missed a section that shows how to implement it. Please let me know if you can implement your ChromiumWebBrowser in WPF with all the code directly in the XAML following traditional MVVM Bindings to ICommand arguments to be executed in the ViewModel that is bound to the View that holds the ChromiumWebBrowser. Thanks.

djangojazz avatar Jul 05 '18 23:07 djangojazz

Welcome! If you're reporting a bug, please make sure you have completed the bug report template see https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md#bug-report. Please make sure you provide enough detail that someone else can reproduce the issue you are experiencing. We prefer to keep this issue track just for bug reports. If you have a question or need help with something I'd ask that you self close this issue and have a read over https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md it contains background information, details on where to ask your questions (hint, Gitter is one such place) It's also reportant to remember that CefSharp is just a wrapper around the Chromium Embedded Framework(CEF), a lot of questions people have aren't actually CefSharp specific, they're generic to CEF and for those CEF has it's own support forum at http://magpcss.org/ceforum/index.php and issue tracker at https://bitbucket.org/chromiumembedded/cef

welcome[bot] avatar Jul 05 '18 23:07 welcome[bot]

Issue tracker is for bug reports only, thank you!

If you have a question, ask it on Gitter, StackOverflow or use ceforum (for questions specific to CEF).

If you are new to CefSharp then we suggest you read https://github.com/cefsharp/CefSharp/wiki/General-Usage

amaitland avatar Jul 06 '18 00:07 amaitland

Is there any way to invoke the Context Menu directly in the XAML like:

You can, though it wouldn't be a true context menu showing the relevant commands appropriate for the element your mouse is currently over. You can implement IContextMenuHandler to disable the build in version.

Please let me know if you can implement your ChromiumWebBrowser in WPF with all the code directly in the XAML following traditional MVVM Bindings to ICommand arguments to be executed in the ViewModel that is bound to the View that holds the ChromiumWebBrowser

You can implement IContextMenuHandler and setup the bindings in code that still attach to your view model. The reality is for many of the advanced features you'll need to implement in code.

amaitland avatar Jul 06 '18 00:07 amaitland

I will ask a question on Stack Overflow, thanks for the response. I am implementing IContextMenuHandler but when you set it to false for the 'RunContextMenu' implementation it will not read your XAML menu items. The question really refers to the implementation given in the example under 'Framework.ContextMenu' that is commented out. People reference this in other Stack Overflow arguments yet it is commented out in the current source code.

djangojazz avatar Jul 06 '18 15:07 djangojazz

Stack Overflow issue filed: https://stackoverflow.com/questions/51214302/trying-to-use-xaml-binding-to-vm-with-cefsharp-chromiumwebbrowser-appears-to-not

djangojazz avatar Jul 06 '18 16:07 djangojazz

I am implementing IContextMenuHandler but when you set it to false for the 'RunContextMenu' implementation it will not read your XAML menu items.

You need to return true to display your own custom menu.

The question really refers to the implementation given in the example under 'Framework.ContextMenu' that is commented out.

Removed in commit https://github.com/cefsharp/CefSharp/commit/709645a195d2cc4d7df0b61529de3e27d3226e6f

It's not used in the example and I don't recommend this approach.

amaitland avatar Jul 09 '18 10:07 amaitland