0

I have a problem in my wpf project. I have a webbrowser control. What I want is to know whether anybody has clicked on the webrowser control. I used the mousedown event. But to my surprise it is not firing the event. In the webbrowser control I find that only Navigated and Navigating events are fired. Please let me know how can I get mousedown event? Thanks for your time.

MACMAN
  • 1,883
  • 1
  • 21
  • 35

3 Answers3

2

Mouse events are not supported by the WebBrowser control. Please refer to the following (duplicate) question for more information about how you could solve this.

WPF WebBrowser Mouse Events not working as expected

Community
  • 1
  • 1
mm8
  • 163,881
  • 10
  • 57
  • 88
1

MACMAN, add event handler manually, like this:

public MainWindow()
{
InitializeComponent();
AddHandler(FrameworkElement.MouseDownEvent, new MouseButtonEventHandler(WebBrowser_MouseDown), true);

ps: See this topic: https://social.msdn.microsoft.com/Forums/en-US/61807025-d4c4-41e0-b648-b11183065009/mousedown-event-not-working-wpf?forum=wpf

rud0x1
  • 88
  • 7
0

I got the solution by injecting javascript that adds a html mousedown event to the website. The javascirpt in turn invokes a wpf function that is written into a class using ComVisible[true].

http://sekhartechblog.blogspot.in/2012/04/webbrowser-javascript-communication-in.html

MACMAN
  • 1,883
  • 1
  • 21
  • 35