Question

I have a WPF (VB) project, where I placed an Awesomium Browser Control. I am able to browse, and I am able to right click on it and see the default right click menu items.

My goal is to add new custom items to that right click context menu programmatically at the runtime as well as route it to some event to handle the logic.

According to the WebControlContextMenu Class Documentation on the awesomium.com web site - I am limited to 2 options:

  1. Redefine a WebControlContextMenu application resource, using the ContextMenuResourceKey as key.

(Completely substitutes the default context menu. You should bind the DataContext property to the PlacementTarget property, to access the WebControl. You can later use the [!:WebViewContext] provided through LatestContextData to update the state of the menu's items.)

  1. Assign your own context menu to the ContextMenu property. (Same as before but in this case you should provide your own display context data.)

I have tried to create a basic ContextMenu with basic ContextMenu and add some items but I could not figure how to add this menu to the existing Web Control.

I can post my piece of code but none of my code has been working so far.

Where do I start and is there a demo that maybe helps to understand it better. Any piece of code that could give me some idea is highly appreciated!

Was it helpful?

Solution

Alexey F Shevelyov:

Our team came up with the following solution to address the problem:

Public Sub Test() Handles Browser.ShowContextMenu
    Dim oArray(2) As MenuItem
    Dim oMenuItem As New MenuItem
    oMenuItem.Header = "Who Runs It ?!?"

    oArray(0) = oMenuItem

    Dim oMenuItem1 As New MenuItem
    oMenuItem1.Header = "Brogrammaz"

    oArray(1) = oMenuItem1

    Dim oMenuItem2 As New MenuItem
    oMenuItem2 .Header = "Get Some..."

    oArray(2) = oMenuItem2 

    Application.Current.Resources.Clear()
    Application.Current.Resources.Add(WebControl.ContextMenuPageItemsArrayRecourceKey, oArray)
    Application.Current.Resources.Add(WebControl.ContextMenuInputItemsArrayRecourceKey, oArray)
End Sub here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top