我有XAML这样可以让我在第三方地图控件添加这发生在视图模型添加第三方控件到视图模型中解耦方法
<UserControl x:Class="AssemblyName.Views.CustomMapView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AssemblyName.Views"
xmlns:ioc="clr-namespace:AssemblyName.Ioc"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
ioc:ViewModelLocator.AutoWireViewModel="True">
<esri:MapView x:Name="customMapView">
<esri:Map x:Name="customMap">
<esri:ArcGISTiledMapServiceLayer ID="BaseMap" ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map>
</esri:MapView>
</UserControl>
我所有的业务逻辑,需要与此控件交互并让它做事情。理想情况下,我希望视图不知道它是什么类型的控件。我做这一切与用户控件的时间通过在XAML中的条目,如:
<ContentControl Name="menuControl" Content="{Binding MenuControl}"/>
然后视图模型可以设置任何“菜单控制”对象,自ContentControl继承。
因为customMapView
不从ContentControl继承,我不能使用上面我通常使用的方法。它从Control继承。
有没有一种方法可以放入标准<control/>
并将我的地图控制分配给它?
基本上,我只是想以最可能的解耦方式与ViewModel中的Map对象进行交互。
那很简单,呃?我会在今晚晚些时候尝试这个 – matrixugly
钉住它......这比我想象的要容易得多。谢谢! ContentControl ftw。 – matrixugly
很高兴我能帮到你 –