- What are the advantages and disadvantages between using WPF (Windows Presentation Foundation) over Winforms?
- What are the considerations that need to be made when choosing between the two?
Thanks.
Thanks.
The biggest consideration when deciding which one to use is what Framework will your target audience have installed? I find that more people have the lower Framework versions that only support Winforms, but that's just my personal experience.
WPF's support for declarative UI through XAML, rich controls templating and styling and tools like Blend, makes it lot better for designers to work with developers on the same project. Plus, it gives the developers the flexibility of attached dependency properties and the extremely powerful databinding. In addition Silverlight supports a subset of XAML and the same control classes as WPF, so your application can be ported as RIA with minimal efforts.
I would choose WPF over WinForm any day. Even if the target machines have only .Net 2.0, if the user can install additional programs, the new .NEt Framework Client profile makes it quite easy to deploy WPF applications.
The only reason I might decide to stick with WinForms is if the product will be deployed on machines that are locked down and have only .Net 2.0 or .Net 1.1.
The advantages of WPF is that it is much easier to create nice looking GUI's with custom controls and animations. WPF also helps further serparate the presentation and logic layers. If you have designers, it allows you to farm of 95% of this work to non-coders and allows the coders to work on logic. The disadvantages are the software costs for Expressions Blend, and the lack of any of the Visual Studio code profiling tools working well as they tend to get caught up in the frameworks calls in trying to render XAML. I am sure there are others but these were the only two we really saw.
The main consideration is if you wish to require your customers to have to install .NET 3.0 or even better .NET 3.5 SP1. You will get some niegative feedback
There are many differences. We loved WPF for:
However, we stuck with Forms because:
As others have said, there are advantages and disadvantages either way you go here. The advantages of WPF, as others have said, include:
However, there are drawbacks to WPF, where WinForms comes out on top:
Finally, bear in mind that you can create great, attractive and engaging UIs in either tool, if you do the work (or use the right 3rd party tools). At the end of the day, neither is necessarily better in all circumstances. Use what feels right for the project.
Hi! What about performance of WPF? What are the REAL hardware requirements?
Cheers from Argentina!
Are there any compelling reasons to use WPF
Absolutely! WPF is absolutely incredible! It will be a major benefit for practically any project because it has so many features and abilities that WinForms lacks.
For business applications the biggest wins will be:
For utilities and games, other advantages come to the forefront:
The bottom line is that any significant-size GUI you could build in WinForms can be built in WPF in a third of the effort (or less) and look way, way better.
Does WPF require more resources (RAM in particular)
You do pay a price compared to WinForms, but it is a small one.
One more note about CPU use: Animations and transforms (motion, translation, etc) is actually more efficient on WPF than in WinForms because of its retained mode storage. It is the initial getting of the objects up there that is slower.
Maintenance overhead
WPF is a huge win over WinForms when it comes to maintenance. Since everything is done in 1/5 as much code as before, there is 1/5 as much to maintain. Plus all the boilerplate stuff is gone so you can focus on the code that actually does the work.
Benefits of XAML
XAML is the core of WPF. Although WPF can be used without XAML, XAML makes it incredibly easy to use. XAML has HTML's ability to easily specify a user interface, but its' built in tags are much more powerful, and you can easily define your own. (In fact, it is normal to do so).
Some specific advantages of XAML:
Other insights
I dreamed of something like WPF for many years. Many people have implemented portions of this functionality, but to get it all in one place and at such a price ($0) is amazing.
WPF is a huge paradigm shift from WinForms and will take some getting used to, but the time spend learning it will pay itself back many-fold.
WPF still has a few warts even 5 years later, but its power will totally blow you away once you experience it. If someone tries to drag you back to WinForms, you'll only go kicking and screaming.
Tips: - Do get a copy of Expression Blend for development - Do edit XAML by hand occasionally - Don't give up when it seems strange at first
There is a known issue with text rendering in WPF. Many users report that the heavy use of anti-aliasing and pixel-blending used causes blurry text. This is a big deal breaker in some circumstances and, as far as I know, has been acknowledged by Microsoft at some level.