The long-standing topic of WinForms versus WPF for Revit add-in user interface seems to be nearing a conclusion:
An extensive discussion in the Revit API discussion forum on the question of using WinForms or WPF in Revit add-ins is pretty clearly recommending WPF as the better choice, for various reasons:
The only downside seems to be that many existing samples in the Revit SDK and elsewhere use WinForms.
That said, the Revit IFC open source UI does use WPF, so you could grab all the samples you need from there, if you like.
Here is a pretty fine 56-minute guide for getting started, the C# WPF UI Tutorial:
The latest contribution to this thread comes from Micah kraftwerk15 Gray:
We were having a conversation on Twitter and had Petr Mitev share a template example of WPF in the Revit WPF Template GitHub repository.
I'm sure there are others out there, but this adds in the Revit context that those building for the Revit API will have to get used to. Many existing examples will not show how the WPF interacts with the Revit API.
Ever so many thanks to Micah and Petr for putting together, sharing and documenting this valuable resource!
The template is well documented and includes built-in support for automatic documentation of the add-ins you create using it.
Here are some excerpts from the GitHub readme file:
WPF Template for Revit Add-Ins including wrapped external methods for execution in a "Valid Revit API Context".
.sln
at the root of the repository with Microsoft Visual Studio.RevitAPI.dll
and others which may be missing.In order to use this as a starter for your application, make sure you first refactor the content in the application files (namespace, assembly name, classes, GUID, etc.) and remove the assets
folder in the repository.
A guide to refactoring can be found in the docs folder.
Documentation is created using Sandcastle Help File Builder by
compiling the docstrings from the compiled .dll
and .xml
files generated by Visual Studio upon build.
The Sandcastle project can be launched through
the RevitTemplate.shfbproj
file in the docs
folder.
The documentation can be found in the docs
folder in the root of the repository.
The following documentation sources are created:
.chm
– This is an interactive help file which can be launched by double-clicking on any Windows machine.index.html
– This is the documentation compiled for web deployment.