This is a migrated thread and some comments may be shown as answers.

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

5 Answers 141 Views
Map
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 21 Dec 2011, 12:41 PM
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

5 Answers, 1 is accepted

Sort by
0
Ian
Top achievements
Rank 1
answered on 21 Dec 2011, 01:14 PM
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....
0
Andrey
Telerik team
answered on 23 Dec 2011, 04:03 PM
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 >>

0
Ian
Top achievements
Rank 1
answered on 26 Dec 2011, 11:40 AM
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

0
Jeff
Top achievements
Rank 1
answered on 27 Dec 2011, 10:51 PM
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.
0
Sia
Telerik team
answered on 29 Dec 2011, 10:03 AM
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 >>

Tags
Map
Asked by
Ian
Top achievements
Rank 1
Answers by
Ian
Top achievements
Rank 1
Andrey
Telerik team
Jeff
Top achievements
Rank 1
Sia
Telerik team
Share this question
or