views:

42

answers:

1

Given only an (x,y) point on the screen (without being allowed to use the mouse), how can you manipulate a custom UserControl?

For example, I have a custom slider that I want to manipulate using only an x, y returned by a vision code (the vision code acts like a mouse, but I am not actually supposed to use the mouse).

A: 

How does the mouse normally interact with the custom UserControl? Does the UserControl have an EventHandler when the mouse clicks/moves on it? If so, you can call the Control's Mouse_Click event (for example) from elsewhere in the code and pass in the arguments that you want. You can do this with code logic or other controls with the same parent as your UserControl.

Ideally, you can set your UserControl up so that it doesn't interact with the mouse directly. Rather, the Control and Mouse both get/set a shared variable representing the XY of the mouse. This makes things easier to test. What you want to use is Binding.

bufferz