MapViewer hosted in a WPF


PurposeMicrosoft's Windows Presentation Foundation (WPF) provides the facility to host Windows Forms controls within a WPF application. This sample demonstrates how to host the ArcGIS Engine Map control, Toolbar control, and TOC control on a WPF window by using the WindowsFormsHost control. A combination of code and Extensible Application Markup Language (XAML) is used to view a map inside the WPF application.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Start Visual Studio 2008 and open the solution.
  2. Press F5 to build and run the project.
  3. Click Open on the toolbar to load a .mxd file onto the map or click Add Data to browse to the data.

App.xaml.cs Perform ArcGIS Engine license initialization when application starts.
MapWindow.xaml Declare the layout of map viewer on a WPF window.
MapWindow.xaml.cs Programmatically host ArcGIS Engine controls and set their properties within a WPF window.
Download the C# files
Application.xaml.vb Perform ArcGIS Engine license initialization when application starts.
MapWindow.xaml Declare the layout of map viewer on a WPF window.
MapWindow.xaml.vb Programmatically host ArcGIS Engine controls and set their properties within a WPF window.
Download the VB.NET files

Download the files for all languages

See Also:

How to host an ArcGIS Engine MapControl in a WPF application
WindowsClient.NET
Walkthrough: Hosting a Windows Forms Composite Control in Windows Presentation Foundation




Additional Requirements
  • Microsoft Visual Studio 2008 installed
  • .NET Framework 3.5 as target framework

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo