aesalazar

Creating combobox item for toolbar extention - no HWND in WPF

Discussion created by aesalazar on Jan 25, 2013
Hi Guys.

I am working an an extension for ArcGIS Desktop in Visual Studios and .net 4.0.  I Have created a working shell with a few buttons and some basic code to make sure everything will work as I like and am stuck on one last thing.

I would like to add a combo box to the toolbar (like the Map Scale drop down in the "Standard" toolbar of arc).  I found the form-based sample solution provided by ESRI called GraphicsLayerToolControl which has been a big help.

But here is where I am stuck.  I am trying to do it all in WPF and the MVVM pattern.  I created a UserControl like in the sample but when I try to complete the command class for it I cannot properly build the required hWnd property.  Since this is WPF there is no native handle to be had.  I thought I could use the Interop function HwndSource.FromVisual to get it but that comes back null.  I think the problem is there is no equivalent "CreateControl()" function in WPF that the forms-based example relies on to force creation of the control  This is what that looks like:

    public int hWnd
    {
      get
      {
        //pass the handle of the usercontrol
        if (null == m_graphicsLayerListCtrl)
        {
          m_graphicsLayerListCtrl = new GraphicsLayersListCtrl();
          m_graphicsLayerListCtrl.CreateControl();  //CANNOT FIND ANYTHING SIMILAR IN WPF
        }

        return m_graphicsLayerListCtrl.Handle.ToInt32();

      }
    }


Is there a way to make this work or am I forced to do a forms-based usercontrol?

Thanks
Ernie

Outcomes