Click here to Skip to main content
15,893,668 members

Incorrectly triggered mouse events for custom panel due to InvalidateArrange() ?

ICube 2 asked:

Open original thread
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.
Tags: Silverlight5, Silverlight (Silverlight5), Mouse, Handler

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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