Friday, January 23, 2015

Parenting Win-form and WPF form in ArcMap

Parenting of Win-form windows and WPF windows within a ArcMap application using C#.Net code snippets-

Step 1: Create a ArcMapWrapper.cs, wrapper class

        using System;
        using System.Windows.Forms;
        using ESRI.ArcGIS.Framework;

        namespace ArcMapClassLibrary2
               class ArcMapWrapper:IWin32Window
                    private IApplication _arcMapApplication;

                    public ArcMapWrapper( IApplication mApplication)
                       _arcMapApplication = mApplication;

                    public IntPtr Handle
                       get { return new IntPtr(_arcMapApplication.hWnd); }

Step 2: Access from Win-form

              WinForm fm = new WinForm();                        
              ArcMapWrapper wrapper= new ArcMapWrapper(map_application);  
              fm.ShowInTaskbar = false;        

              //Try, it behaves like a modal dialog

Step 3: Access from WPF Window

            WpfForm ws = new WpfForm();
            ArcMapWrapper wrapper = new ArcMapWrapper(m_application);

            var helper = new WindowInteropHelper(ws);
            helper.Owner = wrapper.Handle;
            ws.ShowInTaskbar = false;

           //Try, it behaves like a modal dialog      
           //ws. ShowDialog()

ArcMap , arcobject , C#


Post a Comment


© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me