Home:ALL Converter>Wrapping ArcGIS Map into ItemsControl (ItemsControlProxy)

Wrapping ArcGIS Map into ItemsControl (ItemsControlProxy)

Ask Time:2016-10-26T20:08:20         Author:artganify

Json Formatter

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 Layers (used for serialization purposes). Now since ArcGIS is not really MVVM friendly (most 'Controls' are just DependencyObjects, 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 DataTemplates 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?

Author:artganify,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40261875/wrapping-arcgis-map-into-itemscontrol-itemscontrolproxy
yy