A
Adam Clauss
We have a canvas on which we have implemented the ability for the user
to click and drag to "pan" the view. When the mouse button clicks, we
capture the mouse and as mouse move events occur, we apply a transform
to the canvas to cause the pan effect.
On this canvas, we have hundreds (maybe thousands) of shapes. Lately,
we have begun seeing a performance hit during the panning (panning gets
very choppy). During the pan, one CPU core is effectively maxed out. I
used the Visual Studio profiler to see where we were spending our time.
60% of all samples taken were in a chain of "hit test" methods within
the WPF. I assume this is performing hit testing on all our shapes as
the mouse moves. Is there anyway to prevent this? I have tried setting
IsHitTestVisible on our various shapes - that dropped it to 30%, which
is better, but is STILL a decent chunk of time doing something we do not
want.
Incidentally, we generally do want hit testing - (all these shapes are
'click-able'), just not during a pan operation. During a pan operation,
we know the operation did not start "on" a shape, and since we are
panning the canvas with the mouse movement, we know that the mouse will
not be on top of a shape until some time AFTER the pan operation
finishes. Any ideas on how we might accomplish this, especially since
IsHitTestVisible did not seem to quite do enough to really shortcut the
hittesting process?
Thanks,
Adam
to click and drag to "pan" the view. When the mouse button clicks, we
capture the mouse and as mouse move events occur, we apply a transform
to the canvas to cause the pan effect.
On this canvas, we have hundreds (maybe thousands) of shapes. Lately,
we have begun seeing a performance hit during the panning (panning gets
very choppy). During the pan, one CPU core is effectively maxed out. I
used the Visual Studio profiler to see where we were spending our time.
60% of all samples taken were in a chain of "hit test" methods within
the WPF. I assume this is performing hit testing on all our shapes as
the mouse moves. Is there anyway to prevent this? I have tried setting
IsHitTestVisible on our various shapes - that dropped it to 30%, which
is better, but is STILL a decent chunk of time doing something we do not
want.
Incidentally, we generally do want hit testing - (all these shapes are
'click-able'), just not during a pan operation. During a pan operation,
we know the operation did not start "on" a shape, and since we are
panning the canvas with the mouse movement, we know that the mouse will
not be on top of a shape until some time AFTER the pan operation
finishes. Any ideas on how we might accomplish this, especially since
IsHitTestVisible did not seem to quite do enough to really shortcut the
hittesting process?
Thanks,
Adam