I’m using a TreeView that’s bound to my Map’s Overlay + Layers. I noticed that when calling the Layers.MoveUp and Layers.MoveDown functions, the TreeView does not update properly. It “duplicates” the item in the TreeView. I tested it out with a normal ObservableCollection instead for my Overlays and Layers and it worked fine. So I think it could be something in GeoCollection not working properly.
Here’s my xaml for the TreeView:
<TreeView ItemsSource="{Binding OverlaysViewSource}" Name="LayersTreeView">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Layers}" >
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}" />
</StackPanel>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}" />
</StackPanel>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Here’s the related viewmodel code:
/// <summary>
/// The map's overlays.
/// </summary>
public GeoCollection<Overlay> Overlays { get; set; }
/// <summary>
/// Filters out the overlays that match the names for user overlays
/// </summary>
public ICollectionView OverlaysViewSource
{
get
{
var itemsToFilter = CollectionViewSource.GetDefaultView(Overlays);
itemsToFilter.Filter = i => (i as Overlay).Name != "useroverlay1" &&
(i as Overlay).Name != "useroverlay2" &&
(i as Overlay).Name != "useroverlay3";
return itemsToFilter;
}
}
public LayersViewModel()
{
Overlays = MyMap.Overlays; // populates the Overlays collection
}
I’m then calling these two functions to move layers up and down:
Overlays[overlayName]).Layers.MoveUp(layer.Name);
Overlays[overlayName]).Layers.MoveDown(layer.Name);
Below is a .gif showing the behavior I’m seeing. The red arrow up button moves the selected layer object up (towards index 0), and the red arrow button down moves the selected layer object down (towards the last index):
Could a developer check the code in GeoCollection and see if it’s working probably?

