Click here to Skip to main content
15,886,769 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In Silverlight I've created a panel that derives from standard Panel class and have overridden the InvalidateMeasure() and InvalidateArrange() methods. The Panel uses an own Attached Property "Position" of type Point to specify the position of objects. Whenever the attached property is changed, I call InvalidateArrange() to refresh the rendered positions.
In addition I use Animations for smooth drag'n drop-transitions that are attached to the Position-property. If now such an animation is executed, the InvalidateArrange() method is consequently called several times.

A strange effect is now that MouseEnter- or MouseLeave-events on other children of the panel are triggered, even though the mouse pointer is far away from them. Also the Hit-Testing does not work correctly after an InvalidateArrange() is triggered.
That is the case even though typically only the position of one child (the dragged one) actually changes in ArrangeOverride().

If I analyze the relative position of the mouse pointer in the erraneously triggered MouseEnter-event handler, I can even programmatically check that the pointer is outside the triggering child-element: The coordinates of the returned points p and p2 below are mostly negative in such a case.

C#
void Child_MouseEnter(object sender, MouseEventArgs e)
       {
                Point p = e.GetPosition(this);                
                Point p2 = e.GetPosition(e.OriginalSource as UIElement);


Has someone made similar experiences ? At the moment I can only think of a bug in Silverlight.

Additional info: the panel is used inside a ScrollViewer.
Posted
Updated 29-Aug-12 23:01pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900