I need to bind an ArcGIS Map
from the ArcGIS Runtime SDK for .NET to a view model which provides a collection of custom models which represent the data of the individual ArcGIS Layer
s (used for serialization purposes). Now since ArcGIS is not really MVVM friendly (most 'Controls' are just DependencyObject
s, have no data context or don't support templating), my initial idea is to wrap the MapView
in a custom control which derives from ItemsControl
which I bind to my custom types and then select the appropriate DataTemplate
for the type which contains an ArcGIS Layer
that is being rendered into the map. Something like this:
<local:MapViewAdapter ItemsSource="{Binding MyCustomTypes}">
<local:MapViewAdapter.Resources>
<DataTemplate DataType="{x:Type ArcGISDrawLayer}">
<GraphicsLayer GraphicsSource="{Binding LayerGraphics}" />
</DataTemplate>
...
</local:MapViewAdapter.Resources>
</local:MapViewAdapter>
The MapViewAdapter
should internally create a new MapView
along with it's Map
and then render the specified DataTemplate
s into the LayerCollection
of the Map
.
However I have no idea how to accomplish this without re-implementing most of the ArcGIS controls. Any ideas?