Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WinForms or WPF?

24 REPLIES 24
SOLVED
Reply
Message 1 of 25
Dale.Bartlett
4139 Views, 24 Replies

WinForms or WPF?

I am developing a new set of addins and don't know whether to launch into the brave new world of WPF or stick with trusty WinForms. Does anyone have some experiences and comments to share? I have a preference to hone new skills (WPF), but don't want to find myself in a dead-end. I am looking at ContentGeneratorWPF from the SDK for some guidance. Thanks again, Dale




______________
Yes, I'm Satoshi.
24 REPLIES 24
Message 2 of 25

Dear Dale,

 

The development team says that WPF works fine (1).

 

I have never heard anyone having problems with Winforms.

 

I have repeatedly heard abour serious problems with WPF.

 

Serious as in insurmountable.

 

And yet, cf. (1).

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 25

I would say that if you plan a "classic" UI, then WinForm should be easier (as you already know it). If you plan a "innovative" UI, then WPF can bring better results...

Technically, in my opinion, WPF is easier when you have dynamic UIs, where the binding mechanism works really good

My 2 cents...
Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 4 of 25

Hi guys, Thanks for the opinions. I was keen to use WPF as a means to develop new skills, however I think I will stay with old reliable WinForms. Regards, Dale




______________
Yes, I'm Satoshi.
Message 5 of 25
mastjaso
in reply to: Dale.Bartlett

This is an old thread but it's still highly ranked on Google so I just wanted to chime in that I went down the WinForms path for about a year and I really regretted it. I would highly recommend that everyone go down the WPF route.

For one, WinForms often have some serious and practically unsolvable scaling issues on high resolution monitors. You can read some more discussion here, and while Inter-Process Communication (IPC) is a good option for fixing this user's existing code base, implementing IPC is way more work than just using WPF to begin with, since WPF apps don't have scaling issues.

Additionally WPF UIs are built in a much more modern way, with XML layout documents, separate style documents, and separate code / logic documents. This is much more similar to how UIs are built on other frameworks (like Android / iOS / macOS  / web development) and will better prepare you for expanding your development knowledge. This separation also tends to produce much cleaner, more flexible, and more reuseable code.

And lastly, because WPF is a more modern framework, I find that it's just far easier to produce apps that actually look good, and that my users actually enjoy opening up. As developers it's easy to focus on the back end data, but if you want to make a tool that people actually use, it needs to have a pleasing UI, and the styling / dynamic binding nature of WPF makes it far far far easier to produce at least halfway modern UXs.

Message 6 of 25
Dale.Bartlett
in reply to: mastjaso

Thanks for the very informative reply. I have stuck with Winforms, but your points are all valid. Next time... Dale




______________
Yes, I'm Satoshi.
Message 7 of 25

I just read the Building Coder article you mentioned, which only just now hit my inbox. Looks like I need to add WPF to the list of things my rapidly shrinking brain should master. Dale




______________
Yes, I'm Satoshi.
Message 8 of 25
jeremytammik
in reply to: mastjaso

Dear Jason,

 

Thank you very much for reviving this thread, your Revit Idea Station wish list entry to update the SDK and developer documentation to WPF and your forum contribution on this topic.

 

I added them all up to the main blog post on Scaling an Add-In for a 4K High Resolution Screen to ensure they receive the attention they deserve.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 9 of 25

The revival of this question after about 4 years is really timeous and welcome as I am struggling to make the decision as to whether to go with Winforms or WPF. My preference by far would be Winforms as that is where my .NET experience is and development would be significantly quicker and easier. My experience of WPF is limited mainly to experimenting with the Revit API using WPF. On the one hand the responses from 2015 (Winforms works and possible insurmountable problems with WPF) along with the baffling (in the circumstances) fact that the documentation, samples, forums and tutorials are all, or mostly, Winforms and only now is this being addressed on the Ideas board (thank-you). On the other hand however, when working with Revit and the API it frequently feels that development should be done in WPF but never unambiguously so. This is especially when it comes to dockable panels, grids, 'hiding' and showing forms vs panels, and two way 'real-time' interaction between Revit models and the plug-in. I am still relatively new to Revit and the API so I may be way off track here. I am sort of hedging my bets at the moment by creating a WPF project so I have at least got all the WPF scaffolding etc in place and can switch later if necessary but doing most of the development in Winforms. My understanding is that it would be to all intents and purposes not feasible the other way around i.e. a Winforms project using WPF. For many the 'moderness' and improved visual appearance seem to be factors favouring WPF but this is not the case for me. The priorities are functionality and development speed. It is at least good to see that I am not the only one who is a little confused here so some guidance regarding whether to use Winforms or WPF would be appreciated before the point of no return is passed.

Message 10 of 25

@development6P2VK 

 

I can promise you, if you understand WinForms you will be able figure out WPF. And once you do, i highly doubt you will want to go back... The most difficult concepts for me to grasp when making the switch from between the two were the depth and power of Binding, the MVVM pattern and how it is "best" implemented, and XAML itself.

In winforms i was very used to using the visual designer when making a form, and while you CAN do that with WPF it gets really confusing and annoying... WPF just isn't a direct jump in concepts from WinForms, it all depends on what you already know... But i know you lose all the power WPF has to offer if you do not follow some form of the MVVM pattern. Now i mostly type out the XAML directly.


I have had no issues with the Revit API and WPF since at least the beginning of 2018 that were not directly related to me screwing something up with binding, which is on me not WPF or the API. Winforms will stay winforms, you already know how to do that - but it's supposed to be going away, and from a development standpoint i would urge you to give WPF a shot.

Message 11 of 25

I would suggest WPF too , there is more learning, but it is worth. Plus you can dock WPF to a revit windows(I don't thing you can do it with forms, but I can be wrong). Scaling in WPF is much better.
I find a pretty fine guide for WPF:
https://www.youtube.com/watch?v=Vjldip84CXQ

Another thing is that WPF is easier to past into different applications

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 12 of 25

Thanks very much for your response. I know I will be able to figure WPF out but development will take significantly longer and introduce alot of uncertainty compared to Winforms especially when it comes to grids where I have extensive libraries for DataGridView etc and I will have to start from scratch with DataGrid and also, however good WPF is, I really don't like the idea of typing out XAML which as far as I am concerned is going backwards. Anyway, I would rather know now which is the best way to go than find out later and based on the replies so far I am fairly certain WPF is the way to go. I must say some offical guidance on this from Autodesk, e.g. advantages and disadvantages of each in the Revit api context would be good. Thanks again for your reply.

Message 13 of 25

I asked the development team whether they could provide any guidance on this.

 

Merry Xmas!

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 14 of 25
Moustafa_K
in reply to: jeremytammik

I would prefer using WPF, shinny attracts. MVVM, is also a very good feature thing, specially when we are dealing with objects vs Views. I didn't face many problems, only a few that i was able to resolve. I would like to know what problems others faced, that i might not experienced yet.

 


-----------------------------------------------------
Moustafa Khalil
Message 15 of 25

Hi Jeremy,

 

I have only just seen your reply. Thank you so much for asking the development team for guidance on this, I really appreciate it. I look forward to hearing what they have to say about it.

 

I hope you had a good Christmas and all the best for 2020.

 

Kind Regards,

 

John

 

 

Message 16 of 25

Thank you for your appreciation. My pleasure entirely. Happy New Year to you too!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 17 of 25

The development team replies:

 

If anyone wants to look at the IFC open source UI , it uses WPF.

 

Happy New Year!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 18 of 25
mastjaso
in reply to: development6P2VK

In my personal experience, there are no downsides to going WPF (regardless of Revit context or not), except for the lack of Autodesk documentation, though that being said, there is ample documentation on how to use WPF generally, and there isn't really much of a difference with using it in Revit. 

I think the hardest part that most people will have is figuring out how to structure the different layers of your application, but tbh that's somewhat hard to teach as it will vary a lot from project to project and I think that intuition just comes with experience and experimentation.

Message 19 of 25
kraftwerk15
in reply to: mastjaso

I thought I would add in for those in the future reading this thread.

 

We were having a conversation on Twitter and had Petr Mitev added a template / example of WPF. 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 use to and where many looking for examples will not find how it interacts with the Revit API.

 

https://github.com/mitevpi/revit-wpf-template

Message 20 of 25
jeremytammik
in reply to: kraftwerk15

Thank you very much for sharing this valuable and well-documented resource!

 

I went right ahead and published it on the blog to ensure as many developers as possible are aware of it:

 

https://thebuildingcoder.typepad.com/blog/2020/01/revit-wpf-add-ins-and-template.html

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community