I have installed the ArcGIS Runtime SDK for .NET (100.1.0)
I created a WPF app from the ArcGIS template (that should come with all the necessary assembly references...).
I have a "MapView" (my XAML file) containing a map to which I would simply like to add a layer to. I used the example from the API documentation. My XAML is as follows:
<Page x:Class="WpfApplication1.Views.MapView"
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:WpfApplication1.Views"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="MapView">
<Grid>
<Grid.Resources>
<esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
<esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
</Grid.Resources>
<Grid>
<esri:MapView x:Name="MyMapView" />
</Grid>
</Grid>
</Page>
In code behind, I do the following after calling the InitializeComponent()
method:
LocalMapService localMapService = new LocalMapService(@"..\..\..\samples-data\maps\water-distribution-network.mpk");
await localMapService.StartAsync();
ArcGISDynamicMapServiceLayer arcGISDynamicMapServiceLayer = new
ArcGISDynamicMapServiceLayer()
{
ID = "arcGISDynamicMapServiceLayer",
ServiceUri = localMapService.UrlMapService,
};
MyMapView.Map.Layers.Add(arcGISDynamicMapServiceLayer);
At this point Visual Studio warns me "Map does not contain a definition of layer [...] are you missing a using directive or assembly reference?"
If I instead decide to add my layer directly from the XAML without writing any code behind:
<Page x:Class="WpfApplication1.Views.MapView"
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:WpfApplication1.Views"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Title="MapView">
<Grid>
<Grid.Resources>
<esri:SimpleLineSymbol x:Key="SLS" Color="Transparent" Width="1"/>
<esri:SimpleLineSymbol x:Key="BlackSLS" Color="Black" Width="1"/>
</Grid.Resources>
<Grid>
<esri:MapView x:Name="MyMapView">`enter code here`
<esri:Map>
<esri:ArcGISDynamicMapServiceLayer Url=... />
</esri:Map>
</esri:MapView>
</Grid>
</Grid>
</Page>
The designer now warns "the name ArcGISDynamicMapServiceLayer does not exist in namespace http://schemas.esri.com/arcgis/runtime/2013"
What am I doing wrong? It looks I'm not loading all the appropriate components of the API even though I'm using the SDK's WPF template... I'm confused.
I'm running Visual Studio 2015 Update 2 on MS Windows Server 2012 (if that is of any relevance!)
The code that you are using is for 10.2 version of the ArcGIS Runtime for .NET. You can see https://developers.arcgis.com/net/latest/wpf/guide/local-server.htm how to work with the local server in 100.1 release.