原文 http://blog.csdn.net/zzahkj/article/details/9102621

1.首先,新建一个WPF项目,添加引用ESRI.ArcGIS.AxControls、ESRI.ArcGIS.System、 ESRI.ArcGIS.Version、ESRI.ArcGIS.Controls、ESRI.ArcGIS.SystemUI,然后拖入 WindowsFormsHost控件到窗体中或者通过在Grid中添加XAML代码实现,如下:

  1. <Grid>
  2. <WindowsFormsHost Height="54" HorizontalAlignment="Left" Name="windowsFormsHost1" VerticalAlignment="Top" Width="576" />
  3. <WindowsFormsHost Height="232" HorizontalAlignment="Left" Margin="0,60,0,0" Name="windowsFormsHost2" VerticalAlignment="Top" Width="133" />
  4. <WindowsFormsHost Height="232" HorizontalAlignment="Left" Margin="139,60,0,0" Name="windowsFormsHost3" VerticalAlignment="Top" Width="437" />
  5. </Grid>

2.为窗体添加一个WindowsLoad事件,名为Window_Loaded,可通过在Window属性里的事件Load里填写Window_Loaded

或者在代码中直接添加Loaded="Window_Loaded"

3.添加AE控件并建立其与WindowsFormsHost控件的联系,

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using ESRI.ArcGIS.Controls;
  15. using ESRI.ArcGIS.SystemUI;
  16. using System.Windows.Forms;
  17. namespace WpfArcGISEngine
  18. {
  19. /// <summary>
  20. /// MainWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. AxMapControl mapControl = null;
  25. AxTOCControl tocControl = null;
  26. AxToolbarControl toolbarControl = null;
  27. public MainWindow()
  28. {
  29. InitializeComponent();
  30. CreateEngineControls();
  31. }
  32. //建立AE控件与WindowsFormsHost控件的联系
  33. private void CreateEngineControls()
  34. {
  35. mapControl = new AxMapControl();
  36. windowsFormsHost3.Child = mapControl;
  37. tocControl = new AxTOCControl();
  38. windowsFormsHost2.Child = tocControl;
  39. toolbarControl = new AxToolbarControl();
  40. windowsFormsHost1.Child = toolbarControl;
  41. }
  42. //在Window_Loaded实现TOC与MapControl控件、ToolBar与MapControl之间的绑定
  43. private void Window_Loaded(object sender, RoutedEventArgs e)
  44. {
  45. tocControl.SetBuddyControl(mapControl);
  46. toolbarControl.SetBuddyControl(mapControl);
  47. ToolbarAddItems();
  48. }
  49. //ToolBar中添加工具
  50. private void ToolbarAddItems()
  51. {
  52. toolbarControl.AddItem(new ControlsOpenDocCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
  53. toolbarControl.AddItem(new ControlsSaveAsDocCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
  54. toolbarControl.AddItem(new ControlsAddDataCommandClass(), -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly);
  55. toolbarControl.AddItem("esriControls.ControlsMapNavigationToolbar");
  56. toolbarControl.AddItem("esriControls.ControlsMapIdentifyTool");
  57. }
  58. }
  59. }

4.最后运行肯定不会成功,因为没有License的初始化,License初始化的方法是在App.xaml.cs中添加如下的代码实现

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Windows;
  7. using ESRI.ArcGIS.esriSystem;
  8. namespace WpfArcGISEngine
  9. {
  10. /// <summary>
  11. /// App.xaml 的交互逻辑
  12. /// </summary>
  13. public partial class App : Application
  14. {
  15. protected override void OnStartup(StartupEventArgs e)
  16. {
  17. base.OnStartup(e);
  18. ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
  19. InitializeEngineLicense();
  20. }
  21. private void InitializeEngineLicense()
  22. {
  23. AoInitialize aoi = new AoInitializeClass();
  24. esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngine;
  25. if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
  26. {
  27. aoi.Initialize(productCode);
  28. }
  29. }
  30. }
  31. }

现在就可以运行了,运行结果如下:

界面有点丑

在WPF中使用ArcGIS Engine的更多相关文章

  1. 如何在WPF程序中使用ArcGIS Engine的控件

    原文 http://www.gisall.com/html/47/122747-4038.html WPF(Windows Presentation Foundation)是美国微软公司推出.NET ...

  2. 使用XAML在WPF项目中承载ArcGIS Engine地图控件开发

    原文 http://blog.csdn.net/flexmapserver/article/details/5868882 用Windows Form进行ArcGIS Engine二次开发时常见的形式 ...

  3. 关于WPF中承载 ArcGIS控件。

    原文 http://www.cnblogs.com/zoe-j/archive/2011/05/18/2050208.html 之前就做过WPF的应用,之前承载的MapGIS的二次开发控件,今天写一下 ...

  4. 安装ArcGIS Engine 9.3

    本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6217003.html 准备: ArcGIS Engine 9.3.crack_for ...

  5. 【转载】Python与ArcGIS Engine的集成

    本文转载自Fransico<Python与ArcGIS Engine的集成>   1 在Python中调用AO类库 1.1  准备工作 本文所使用环境:ArcGIS 10.0.Python ...

  6. VC、OpenGL、ArcGIS Engine开发的二维三维结合的GIS系统

    一.前言 众所周知,二维GIS技术发展了近四十年,伴随着计算机软硬件以及关系型数据库的飞速发展,二维GIS技术已日臻完善.在对地理信息的分析功能上有着无可比拟的优势.一些宏观的地理信息,一维的地理信息 ...

  7. WPF/ArcGIS Engine三维开发和EVC3/4升级到VS项目建议(转)

    系统环境:Windows 7 专业版,Visual Studio 2010,ArcGIS Engine 9.3 1.创建项目 创建一个WPF的项目,必须选择.Net framework 3.5(AE9 ...

  8. WPF & ArcGIS Engine三维开发入门攻略

    原文 http://www.cnblogs.com/Realh/archive/2010/12/14/1906112.html 前些日子在做ESRI的开发大赛,从刚开始接触ArcGIS Engine( ...

  9. 转-ArcGIS Engine中的License设置

    AE开发中的License有两种方法进行设置,一种是通过LicenseControl控件,另一种是通过IAoInitialize接口设置.整个应用程序中只能有一种方式存在,如果进行了两种License ...

随机推荐

  1. 浅谈 qmake 之 shadow build(将源码路径和构建路径分开,一套源码要分别用msvc2008、msvc2008、mingw分别编译又不互相干扰)

    shadow build shadow build 是什么东西?就是将源码路径和构建路径分开(也就是生成的makefile文件和其他产物都不放到源码路径),以此来保证源码路径的清洁. 这不是qmake ...

  2. 《Programming WPF》翻译 第7章 6.视频和3-D

    原文:<Programming WPF>翻译 第7章 6.视频和3-D 虽然详细地讨论视频和3-D超越了这本书的范围,但是获得这些特征的支持是值得的. 视频由MediaElement类型支 ...

  3. 一键安装IIS的点点滴滴——For所有Microsoft的操作系统(下)

    原文 http://www.cnblogs.com/cdts_change/archive/2010/03/09/1681392.html 接着上一篇的讲,下面我们将讨论Windows7.Window ...

  4. 一次处理ORA-07445的历险记(转)

    ORA-07445通常是Oracle调用操作系统的资源出错时出现的[@more@] 事前没有任何征兆,下午5点左右某个关键应用的17台oracle数据库上的数据库实例陆续宕机,赶紧查看alert_lo ...

  5. linux find详解

    find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件. find的使用格式如下: $ find <指定目录> <指定条件> <指定动作> - < ...

  6. UML--建模

    建模公式 这种精华的东西,一定是值得研读和实践的! myself:人,事,物,规则. 人,业务主角.业务工人.参与者.如果应用到教务系统中,就是管理员,主任,老师的关系. 事,业务用例,系统用例. 物 ...

  7. 【转】Android HAL实例解析

    原文网址:http://www.embedu.org/Column/Column339.htm 作者:刘老师,华清远见嵌入式学院讲师. 一.概述 本文希望通过分析台湾的Jollen的mokoid 工程 ...

  8. CF 584B Kolya and Tanya

    题目大意:3n个人围着一张桌子,给每个人发钱,可以使1块.2块.3块,第i个人的金额为Ai.若存在第个人使得Ai + Ai+n + Ai+2n != 6,则该分配方案满足条件,求所有的满足条件的方案数 ...

  9. pyqt QTableWidgetItem多行显示

    def __2(self): t1=QtGui.QTableWidgetItem(self.names.text()) self.tabs.tableinsertinto.setItem(0,0,t1 ...

  10. The Frog's Games(二分)

    The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) ...