0

I was wondering why does the MapItemsControl exists?

enter image description here

Why aren't these right on the MapControl instead?

What was the reason why UWP team had put these properties into a separate class instead of adding these right on the MapControl?

What's interesting (or confusing?) is you can basically add both MapItemsControl and an element to MapControl and it displays all:

<MapControl>
   <MapItemsControl ItemsSource="{Binding Items}" />
   <Border MapControl.Location="{Binding Location}" />
</MapControl>
Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
Don Box
  • 3,166
  • 3
  • 26
  • 55

1 Answers1

2

I think this is to enable grouping of related map items. This enables you to take map items from multiple sources and display them. So if you had for example weather data, and traffic data, you would add two MapItemControl instances to your MapControl and bind the first one to some weather collection and another one to the traffic collection.

Each type of data can also have its own custom ItemTemplate, which is also convenient.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • Hmm, so basically it's like having layers? Layers already exist but I guess since they are not MVVM friendly, having separate MapItemControl is the MVVM friendly way? – Don Box Oct 22 '18 at 10:52
  • Yes, I think this is more MVVM friendly, as you can bind arbitrary data type and provide a custom XAML template which defines how to display it – Martin Zikmund Oct 22 '18 at 10:57
  • Is it correct that if you don't set the ItemTemplate the MapItemControl doesn't display anything? – Don Box Oct 24 '18 at 06:36
  • 1
    I think that is expected. Most controls just show `ToString()` on the item if no template is set, but in case of `MapItemControl` a string would not be very useful either – Martin Zikmund Oct 24 '18 at 06:41
  • It's interesting, there are so many possibilities to add items to MapControl, none give me a way to bind MapControl to an ItemsSource and have the default pins created. – Don Box Oct 29 '18 at 06:37