tags:

views:

165

answers:

1

I have a control in WPF I want to fake a mousedown on that control, with left mouse button I am trying myControl.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1,0,0,0))

but it give me that "Cannot access protected method here"

anybody have idea?

Thanks

+1  A: 

Use IInputControl.RaiseEvent method:

control.RaiseEvent(new MouseEventArgs(...))

Note that if you actually need to simulate a general click (i.e. regardless of whether it's performed by mouse, keyboard, touch input, or other method), or other high-level interaction with the control, you should probably use WPF Automation API instead.

Pavel Minaev