【发布时间】:2017-03-08 19:06:10
【问题描述】:
我需要将 ArcGIS Runtime SDK for .NET 中的 ArcGIS Map 绑定到一个视图模型,该视图模型提供了代表各个 ArcGIS Layers 数据的自定义模型集合(用于序列化目的)。现在由于 ArcGIS 对 MVVM 并不友好(大多数“控件”只是 DependencyObjects,没有数据上下文或不支持模板),我最初的想法是将 MapView 包装在 自定义控件中 派生自 ItemsControl,我将其绑定到我的自定义类型,然后为包含正在渲染到地图中的 ArcGIS Layer 的类型选择适当的 DataTemplate。像这样的:
<local:MapViewAdapter ItemsSource="{Binding MyCustomTypes}">
<local:MapViewAdapter.Resources>
<DataTemplate DataType="{x:Type ArcGISDrawLayer}">
<GraphicsLayer GraphicsSource="{Binding LayerGraphics}" />
</DataTemplate>
...
</local:MapViewAdapter.Resources>
</local:MapViewAdapter>
MapViewAdapter 应在内部创建一个新的MapView 及其Map,然后将指定的DataTemplates 渲染到LayerCollection 的LayerCollection 中。
但是我不知道如何在不重新实现大多数 ArcGIS 控件的情况下完成此操作。有什么想法吗?
【问题讨论】:
标签: c# wpf mvvm arcgis arcgis-runtime