How to get the state of a mouse button in Silverlight outside of button click events?

I have the following situation.

I handle when the left mouse button is pressed in my Silverlight application, and do something while the mouse is held down and the mouse is moving. When the left button is released, I turn off the flag that tells it to make a material and a mouse movement handler and then no longer does the material.

The problem is this: if the user is in the control area, pushes the left button down and exits the control area, and then releases the button and re-enters, the MouseLeftButtonUp event never fires and processing continues until the user clicks the mouse button ...

My workaround was to disable the mouse flag on MouseLeave, but that's not exactly what I'm going to do. I would like to check to see the state of the left mouse button in the MouseEnter event, but I don’t know how.

Does anyone know how I can access the state of a mouse button outside of print events in Silverlight 3? Thank,

Update

After careful research, it doesn't look the way it is possible in Silverlight 2 (and probably 3.) I found this link . If anyone knows of a workaround please let me know.

+2


source to share


1 answer


What you need to do can be accomplished with the UIElement.CaptureMouse method:

http://msdn.microsoft.com/en-us/library/system.windows.uielement.capturemouse%28VS.95%29.aspx



When the UIElement has captured the mouse, it will continue to receive mouse events even if the mouse leaves the Silverlight control.

+2


source







All Articles