How to know the current objects designed in dynamic layer

3 posts, 1 answers
  1. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 19 Oct 2010 Link to this post


    I'm using dynamic layer to draw location points on map, and when I delete a current object and next try to draw it again throws ArgumentException when calling.


    This callback is the callback of the function itemsrequests(). I think that is crashing because the object is already in the dynamic layer. 
    Is there a way to test if the object is already in Dynamic layer. Or what can cause this exception. 

    I really need your help I can't find a sollution.

    Kind regards,
  2. Answer
    Andrey avatar
    1681 posts

    Posted 21 Oct 2010 Link to this post

    Hi Gonçalo,

    You can use the Contains method of the DynamicLayer.Items object to check that the item is already in the layer.

    List<object> objects = new List<object>();
    if (!page.DynamicLayer.Items.Contains(itemToAdd)) 

    Another cause of the ArgumentException with the "Value does not fall within the expected range" error could be in using the Name property of MapShape objects (MapPolyline, MapPolygon etc).
    When you use the Name property then it is still registered in visual tree although it has been removed from the layer. And when you add the map polyline second time then the exception is thrown.

    We have created a PITS issue to fix this problem in future releases.
    You can track it using the following link:

    In this case as workaround use the map polylines without using the Name property or use the Tag property instead.

    Andrey Murzov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Pedro
    Pedro avatar
    25 posts
    Member since:
    Aug 2010

    Posted 21 Oct 2010 Link to this post

    Thanks Andrey :)

    It was the name. Now it works fine.

    Kind regards,
Back to Top