I created a very simple test control that has a Rectangle on the canvas (in other containers, but inconsequential). Rectangle has event handlers for the mouse, mouse, and mouse. If I grabbed the mouse in the Rectangle MouseLeftButtonDown event, I do not get the corresponding MouseLeftButtonUp event.
Some codes:
private void rect1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (_captured = CaptureMouse()) { _offset = new Point(Canvas.GetLeft(rect1), Canvas.GetTop(rect1)); _origin = e.GetPosition(RootCanvas); e.Handled = true; } } private void rect1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_captured) { ReleaseMouseCapture(); _captured = false; e.Handled = true; } }
I hooked up event handlers for the elements of the container, just to make sure that one of them did not receive the mouse-up event in some way, but none of them were. Is there any expectation of this in Silverlight that I have not yet recognized?
source share