InformationLayer bound to ObservableCollection not updating properly (DataTemplate dependant!)

6 posts, 0 answers
  1. Ian
    Ian avatar
    3 posts
    Member since:
    May 2011

    Posted 21 Dec 2011 Link to this post

    Hi Forum,
        Sorry if this is a repeat, I could not find a similar problem on the forums.    

    I am having trouble using the 2011.3.1116.40 version of the telerik WPF controls. I have a WPF Map InformationLayer that has it's ItemsSource bound to an ObservableCollection, and what I was seeing is that changes to the collection were not showing up on-screen until I zoomed in or out.

    My DataTemplate for the InformationLayer contains a UserControl that holds the content and defines the MapLayer.Location property, and this seems to be causing the problem.

     

    I built a sample app to test and found that clearing the items always updates correctly, however when I add items they do not show until I zoom or add another item at a later time (in which case the older item shows but the new item does not.)

    Even when adding multiple items at the same time they do not show up on the map until another item is added at a later time.

    If I change my DataTemplate to wrapper the UserControl in a Grid that sets the MapLayer.Location but is defined as a local resource the items appear immediately.

    In the code below, "HintTemplate" is the DataTemplate that appears immediately, while "HintTemplate2" appears only after a later change to the collection or a Zoom.

    <DataTemplate x:Key="HintTemplate">
            <Grid
                telerik:MapLayer.Location="{Binding Location}"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
                <local:Hint />
            </Grid>
        </DataTemplate>
          
        <DataTemplate x:Key="HintTemplate2">
            <local:Hint />
        </DataTemplate>

     
    I'll use the wrapper approach for now to work around my issue, but would really appreciate it if someone could tell me what I've done wrong. 

    The sample app zips up to 17Kbytes, so I can easily provie it if that will help explain my issue.

    Thanks,
        Ian Barnes

  2. Ian
    Ian avatar
    3 posts
    Member since:
    May 2011

    Posted 21 Dec 2011 Link to this post

    I'm not able to use the DataTemplated wrapper that solved the delayed appearance outlined above, as I need the MapLayer.Location property to be present on the UserControl so I can drag it. Looking for other suggestions....
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 23 Dec 2011 Link to this post

    Hello Ian,

    We are unable to reproduce the problem.
    Could you, please, provide us with a small sample solution which reproduces it? Thank you.

    Greetings,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Ian
    Ian avatar
    3 posts
    Member since:
    May 2011

    Posted 26 Dec 2011 Link to this post

    Ok Andrey,
         I've moved this to a support ticket so I can attach a small project that shows the problem. I've got two templates in the project, one just contains a UserControl and it is not appearing until after a later addition or a zoom operation, the other wraps the UserControl in a grid within the DataTemplate and it works as expected.

    Next I'll be bugging you about what MapPolyline does when the LocationCollection is emptied out (semi randomly placed, non-scaling lines). But one thing at a time.

    Regards,
        Ian Barnes

  6. Jeff
    Jeff avatar
    3 posts
    Member since:
    Nov 2010

    Posted 27 Dec 2011 Link to this post

    Andrey/Ian,

      I've had the same issue in my map application, as well.  Two workarounds that you can try are zooming in and out programatically using ZoomLevel++/--, and the other is to add and remove a dummy object to the observable collection.  It seems like simply adding another object causes the information layer to be completely redrawn.
  7. Sia
    Admin
    Sia avatar
    667 posts

    Posted 29 Dec 2011 Link to this post

    Hi all,

    Thank you for the detailed feedback. As answered in the support thread concerning the same issue, it is already logged in our public issues tracking system. You can track its progress there. Please vote for it in order to increase its priority.

    Meanwhile the suggested workaround is to use the following data template:
    <DataTemplate x:Key="HintTemplate2">
        <local:Hint telerik:MapLayer.Location="{Binding Location}"/>
    </DataTemplate>

    All the best,
    Sia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
UI for WPF is Visual Studio 2017 Ready