Select to view content in your preferred language

Bug with Visuals on map?

992
3
10-18-2011 01:41 AM
Labels (1)
GéraldReusser
Emerging Contributor
I am trying to do provide some in-place editing in some of our custom symbols. So I have to put a textbox inside the symbol templates. Doing so results in crashes in some ArcGis APIs. I tracked down at least one bug:

GraphicsLayer.FindGraphicsInHostCoordinates(Rect) is buggy if the intersectingRect contains the textbox. Here???s why. It first uses VisualTreeHelper.HitTest to find the visuals inside the rectangle, but then casts them to UIElement:
elements.Add(result.VisualHit as UIElement)
The problem with that line is that some Visuals are not UIElement, e.g. when using textboxes. Because of that a null is inserted inside the result.

The next step is calling the private GetGraphicsFromUIElements() method, which doesn???t handle nulls and crashes with a NullReferenceException.

I suspect that GraphicsLayer.FindGraphicsInHostCoordinates(Point) would crash as well since it tries to perform a direct cast:
(UIElement)hitTestResult.VisualHit
which would surely result in an InvalidCastException.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
I was able to reproduce the issue. Thank you for reporting this to us. We will try to get it fixed in future releases of the API.
0 Kudos
GéraldReusser
Emerging Contributor
Thank you Jennifer.

Can you tell me if the fix will be included in the next release (coming soon I think)? Since some of our features depend on it, we would like to know what will be possible in the short term.
0 Kudos
JenniferNery
Esri Regular Contributor
No problem. Your detailed description helped a lot. Yes, it is targeted for v2.3 Final.
0 Kudos