tags:

views:

236

answers:

4

Recently I started using WCF, and I was very impressed, so much so , that I am wondering about getting more into WPF, but my initial experiences with XAML were not that great, about 1 year ago.

Have things improved, is the delivery truly browser independent (can run on browsers other than IE).

Is development productivity increased, better code/ui seperation? Does it require learning silverlight?

If you've had real experience with WPF, please state the pro's and cons.

+10  A: 

First:

WPF is 100% browser independent, because WPF doesn't run in the browser.

XBAP (now deprecated) and Silverlight run in the browser, but both are subsets of WPF.

Second:

The major benefit of WPF is the hierarchical nature of the GUI structures you can create. If you've ever done ASP.NET programming, WPF is a more natural move than WinForms.

Databinding in WPF is different, but better, IMO.

Bottom line: XAML and it's intricacies are a big learning curve, and WPF and XAML go very much hand in hand. But once you understand the basics and can start constructing basic GUIs with it, you'll never want to use WinForms again.

Regarding Pros and Cons, I'd say the only real con to WPF is the large learning curve. It can do everything WinForms can do from a .NET perspective, and is easier to use (once you understand it) than WinForms. The only place it might be "lacking" is in direct GDI+ manipulation, but you'll probably want to avoid that wherever possible. If it becomes necessary in a WPF project, just create a WinForms control and host it in WPF. Not the most elegant solution, but it can get the job done.

Randolpho
So , this replaces classic clunky winform interfaces? And all of this can be done with VS2008?
JL
@JL: Yes. Although you can still do the "drab gray" interfaces with WPF (and it's very easy, IMO) you can do a lot, lot more. Plus you get a major separation of concerns built into the structure of WPF, something you will not get with WinForms.
Randolpho
+2  A: 

Well I have real experience with WPF, but not with WinForms. I've been using WPF for 8 months now, and I find fun, easy to learn, hard to master. The binding, commands & styles which are the most basic WPF features IMO, are really easy to learn and to use. I know commands and style weren't present in WinForms, binding was, but as Randolpho said, it was different.

Also WPF uses DirectX to draw it's graphics now GDI or GDI+, which also gives it a lot more flexibility to draw advanced 2D graphics or even 3D graphics. Also since it sits on top of DirectX, the GPU is used to draw all the graphics instead of the CPU (like GDI), so in a way, you're using less processing power from the CPU.

Carlo
+1 for mentioning DirectX rather than GDI. WPF doesn't use GDI/+ at all, while WinForms thickly wraps GDI/+.
Randolpho
Thanks, I think that's a core difference from WinForms, try doing some 3D rendering with WinForms =P lol
Carlo
Definitely a core difference. But not necessarily for 3D rendering; more for *vector* based drawing. WPF is really still best using 2d rendering via DirectDraw, etc.
Randolpho
+3  A: 

If you're doing in-browser development, you probably want to use Silverlight. It is similar to WPF, but browser independent, and gaining a lot of traction in terms of usage, as well as a lot of attention from Microsoft. (For example, the new RIA services is pretty nice, for business apps.)

Both WPF and Silverlight provide many of the same benefits when compared to older technologies for UI development, though, such as Windows Forms.

  • Databinding in WPF and Silverlight is very powerful, and very flexible. This can both speed up development and provide a level of safety that was difficult to create before.
  • UI development, though different, is much more flexible. The separation of presentation from behavior in WPF and Silverlight makes it very easy to create very customized UI code, very quickly.
  • The new commanding interface, in conjunction with DataTemplates, allows for much easier development in a manner that's very flexible, testable, and maintainble (by using the MVVM pattern).

All of these lead to a much nicer long term development, once you get over the learning curve, in my opinion.

Reed Copsey
+2  A: 

Cons

  1. WPF is not so easy to learn.

  2. WPF is still young. To provide an example: To use a data-grid control you have to download the unsupported WPF toolkit. Silverlight 3 now supports the data-grid natively and I'm pretty sure that VS 2010 will have the data-grid rolled into WPF. But it takes time to mature.

  3. As with any technology don't always trust the samples. I've seen some pretty bad XAML out in the wild (even from Microsoft).

Pros

  1. The user interface is declaratively expressed as a hierarchy of objects represented in XAML instead in a visual designer that only allows interaction via the mouse. (Visual Studio and Expression Blend also have a visual designer that works on top of XAML.)

  2. Composing controls into flexible layout panels and pulling resources from dictionaries allow you to create consistent and beautiful fluent user interfaces. On top of this add rich support for graphical elements like vector drawings, colored gradients, transparency and add to this mix animations and you have the tools to create a truly stunning user experience (or a very horrible one if you don't know what you are doing.)

  3. Controls are composed of layout and behavior. You are able to completely replace the layout and still keep the behavoir. This is much more advanced than an owner-drawn button or a list box with images.

  4. Strong support for data-binding makes it easy to separate the application logic into manageable layers. Never again will you have to toggle a user-interface bit inside a domain model object.

  5. The rendering model in WPF is not the GDI model where your OnPaint method is called to paint a particular area of the window. Instead you add elements to a scene graph (normally expressed in XAML) that is then rendered using DirectX. In many ways this is a much better model.

I'm impressed by the overall design of WPF, and in my oppinion the designers of WPF are really smart people that have done a great job. But working with WPF can still be a frustrating experience either because you havn't figured out the "proper" solution to your problem or because some aspects of WPF simply are annoying (like when you want to customize a tiny part of a built-in control and suddenly are faced with modifying a colossal control template).

As you have probably figured out by now WPF is not Silverlight. Rather Silverlight is a "light" version of WPF in the browser. As Silverlight is somewhat less complex it is actually a very good starting point to get some XAML experience if you don't mind writing a sandboxed browser application instead of a desktop application.

Martin Liversage