5

I want to port a tool developed in ArcObjects for ArcMaps into ArcGIS Pro using the ArcGIS Pro SDK.

The tool's UI was created using WinForms but to recreate the UI in ArcGIS Pro is looks like I would need to use WPF.

I have seen generalized .NET posts online saying that is possible to embed WinForms inside WPF. What I want to know is if it is possible to do so in ArcGIS Pro.

I have not found yet any references or samples of anyone having done it before.

2
  • 2
    Have you tried anything yet? I'd be surprised if it wasn't possible to just use var f = new MyWinForm(); f.Show();. Dockable windows may be harder though. It looks like you'd need WindowsFormsHost to do that: docs.microsoft.com/en-us/dotnet/api/…
    – Berend
    Commented Nov 23, 2018 at 7:52
  • I was able to use win forms within a Pro code-base. The use-age / coding is the same as any *.Net project. However I did not try a dock-able window. This approach though easier when porting code, it misses the "goodness" of the wpf approach. The wpf form controls have some extra functionality e.g. it is easy to change the background colour of a list item in wpf listbox. Commented Jul 20, 2020 at 7:37

4 Answers 4

5

It is technically possible and doable, but building the new ArcGIS Pro .NET Add-in on WPF is the way to go for ArcGIS Pro customizations.

If you are set on embedding WinForms in WPF, you'll use the WindowsFormsHost control.

Below are links to articles and walkthroughs that describe developing for ArcGIS Pro using WPF and MVVM, as well as what you need to do if you are planning to embed WinForms inside of WPF controls.

ProConcepts Migrating to ArcGIS Pro https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Migrating-to-ArcGIS-Pro

ArcGIS Pro SDK for .NET: Intro and Pro Add-in Programming Pattern http://proceedings.esri.com/library/userconf/devsummit-euro17/papers/devsummit-euro_38.pdf

ArcGIS Pro SDK for .NET: UI Design and MVVM http://proceedings.esri.com/library/userconf/proc16/tech-workshops/tw_1853-255.pdf

WPF and Windows Forms Interoperation https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/wpf-and-windows-forms-interoperation

Walkthrough: Hosting a Windows Forms Control in WPF by Using XAML https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml

Walkthrough: Hosting a Windows Forms Composite Control in WPF https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-composite-control-in-wpf

WinForms and WPF: An Integrated Approach https://www.slideshare.net/talentica/winforms-and-wpf-an-integrated-approach

How do I host a Windows Forms control in a WPF application ? https://www.syncfusion.com/faq/929/how-do-i-host-a-windows-forms-control-in-a-wpf-application

0

While I'd encourage you to port your code to use WPF, I don't see why you couldn't just host your WinForms control inside a WPF view. To ArcGIS Pro it's then still just a WPF control - it doesn't really care what's deeper down the UI Hierarchy (because there's no way it can care)

https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf

0

I was looking at the same process for translation from ArcObjects to Pro SDK. I found the learning curve for WPF too steep for the time I had.

A few tests with ordinary Winforms revealed it worked ok. There was no need to embed the forms in a WPF view.

The translation was completed with WinForms and it works fine. When I have more time I'll update the forms to WPF.

1
  • Did you create a Win Forms project in VS and then add the pro libs or how did you use the Prod SDk with Win forms
    – GBh
    Commented Jan 16 at 14:59
0

I was in the same situation as John M, and "just" used winforms instead of WPF forms for my user interaction. I didn't host the forms with wpf, just made sure I had references to System.Windows.forms, designing and using these as in ArcObjects. However there are a couple of things to note: Now you will have 3 sets of Messagbox.Show: System.Windows.Forms System.Windows ArcGIS.Desktop.Framework.Dialogs

Only the last works when used from the module_1. The others cause a "dispatcher processing has been suspened error" which freezes ArcGIS Pro. Instatiating forms from other parts of the project like a command button works fine.

In my internet searches there have been comments that mixing references can lead to trouble. The above may be a sign of that. Also I have not tested Windows.Forms against the asynchronous programming inherent in Pro. I create form use it and close it .... very linear

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.