Select to view content in your preferred language

Bind multiple existing maps to an observable collection in XAML?

750
2
09-12-2010 08:40 AM
RyanCoodey
Frequent Contributor
So our in house toolkit originally just supported one map, and the following example worked great:
<sdl:ViewToolbar x:Name="ViewToolbar" Map="{Binding ElementName=Map1}" />


But now, instead of the ViewToolbar having just a Map property, it has a Maps property, which is an ObservableCollection<Map> (could be any collection type really).  So the control can now support working with multiple maps.  I can set this Maps collection in the code behind, and it works, but I would like to set it in the XAML similar to the above example.  I would like to do something like this:
<sdl:ViewToolbar x:Name="ViewToolbar">
    <sdl:ViewToolbar.Maps>
        <!-- How do I bind to multiple existing maps here? -->
    </sdl:ViewToolbar.Maps>
</sdl:ViewToolbar>


Is this possible?  Can I create a ObservableCollection resource or something and bind to that? Or do I have to do it in code?

Thanks a lot for any help!
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
You can refer to this link for workaround: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/2b5f8ab5-e3ad-4f5f-b1fc-177b29f369d2

It seems like ObservableCollection is not available in XAML. I have tried to include System.Collections.ObjectModel assembly before too and this type is not available in the intellisense. In this forum post, they suggest creating your local class that inherits from ObservableCollection and creating an instance of your class in XAML instead.
0 Kudos
RyanCoodey
Frequent Contributor
Thanks a lot Jennifer!

That is great, and I see what they are doing there... but how do I add/bind an existing map into the collection in XAML?  I don't want to create a new map in the collection, but bind an existing one...

I probably could create a map container class with a map property inside it and then bind to that I suppose... but would be nice to just stick a reference to the map right in a map collection.

Thanks!
0 Kudos