Getting started with Visual Studio
To enhance the developer experience, custom project templates have been added to the Visual Studio integrated development environment (IDE). The ArcGIS Runtime SDK for WPF Integration Framework is an optional installation feature included with the ArcGIS Runtime SDK for WPF install. A project template includes all the files and property settings necessary to begin a specific type of WPF project. You can create new projects for customization by using a project template. The project template is available in the languages Visual C# or Visual Basic.
The ArcGIS Runtime SDK 10.2.5 for WPF Application template demonstrates how to add online and local service layers to your application.
Getting started with the template
- If you haven't already, install and set up ArcGIS Runtime SDK for WPF, which includes adding the references to the needed assemblies.
- In Visual Studio, click File > New > Project. The New Project dialog box appears with the list of installed templates.
- Navigate to Visual C# or Visual Basic > Windows > ArcGIS > Runtime SDK 10.2.5 for WPFand you should see the ArcGIS Runtime SDK 10.2.5 for WPF Application template installed as shown in the following image:
- Click OK.
- The template consists of XAML markup code and Visual C# or Visual Basic code behind.
- In the Project References notice that the ESRI.ArcGIS.Client and ESRI.ArcGIS.Client.Local libraries are present.
- Examine the MainWindow.xaml code in the created project and notice that:
- A Map control has been created and added as the content to the Window.
- there are a number of local and online service layers commented out.
- Uncomment the ArcGIS Online Tiled Basemap Layer which has a URL property set to the world topographic map which is made available for users online.
- Build and Run the application. The map application should appear as follows:
Working with local data
- To customize the template edit the XAML markup and/or the code behind. To work quickly with local data uncomment the XAML markup to add the service layers required. Local tiled basemap layers are often used as a way to help the user of the map orient himself or navigate. Typically any operational layers are placed on top of basemap layers. To use the local tiled basemap layer provided with the SDK samples, enter the relative or absolute path to the data as shown below:
<!-- Local Tiled Basemap Layer -->
<esri:ArcGISLocalTiledLayer ID="arcGISLocalTiledLayer" Path="C:\Program Files (x86)\ArcGIS SDKs\WPF10.2.5\sdk\
samples\data\tpks\Topographic.tpk"/>
- Operational data can be added to the map using Local Dynamic Layers. To add a Local Dynamic Layer uncomment the XAML mark-up and specify the path and layer name as shown below:
<!--Local Dynamic Layer-->
<esri:ArcGISLocalDynamicMapServiceLayer ID="arcGISLocalDynamicMapServiceLayer"
Path="C:\Program Files (x86)\ArcGIS SDKs\WPF10.2.5\sdk\samples\data\mpks\USCitiesStates.mpk"/>
- Local Feature Layers are a special type of Graphics layer that allow you to display graphic features which consist of geometry and attributes. To add a Local Feature Layer uncomment the XAML mark-up and specify the path and layer name as shown below:
<!--Local Feature Layer-->
<esri:ArcGISLocalFeatureLayer ID="arcGISLocalFeatureLayer"
Path= "C:\Program Files (x86)\ArcGIS SDKs\WPF10.2.5\sdk\samples\data\mpks\USCitiesStates.mpk" LayerName="Cities"/>
- Navigate to the Visual C# or Visual Basic code behind. Add the code to start a LocalMapService is and create an ArcGISLocalDynamicMapServiceLayer adding it to the Map control. Specify the path to a Local Map Package and the layer ID of the ArcGISLocalDynamicMapServiceLayer as shown below:
LocalMapService.GetServiceAsync(@"C:\Program Files (x86)\ArcGIS SDKs\WPF10.2.5\sdk\samples\data\mpks\USCitiesStates.mpk", (localMapService) =>
{
ArcGISLocalDynamicMapServiceLayer arcGISLocalDynamicMapServiceLayer = new ArcGISLocalDynamicMapServiceLayer()
{
Service = localMapService,
ID = "Cities",
};
_mapControl.Layers.Add(arcGISLocalDynamicMapServiceLayer);
});
Related Topics
1/27/2015