tags:

views:

292

answers:

3

In WPF i can make my UI using .NET 2.0 style like designer.cs, my question is what are the advantages of using XAML for UI design instead of code.

+6  A: 

The main advantage is that if you keep a clean separation of markup and code (e.g. by applying the MVVM pattern), you can concentrate on the behavior of the application (i.e. the code) and let professional graphic designers about applying the look and feel of the application.

These two tasks can even be worked on in parallel by two different people using different tools (e.g. Visual Studio vs. Expression).

Mark Seemann
In other words, it lets the professionals do the proper work using better tools that a duct tap... err, code. :-)
Franci Penov
Agreed, but I'd add that even if you're not bringing in a separate graphic designer, the discipline of a separate language and the idiomatic nature of XAML (e.g. data binding) still help to create this separation and encourage a clean architecture. WPF and XAML aren't just for design-heavy apps!
itowlson
@itowlson: Well put :)
Mark Seemann
+1  A: 

The main advantage is that you can split the appearance of your application away from the code.

By interacting with the code by use of command bindings and events it allows the business logic to be completely separate to the GUI.

This allows graphic/web designers to concentrate on the front end and coders the business logic. You'll also find that things like animation can be handled completely by the front end in XAML, without any source coding behind it.

This means that you will be able to change all visual aspects of the application without changing any business logic.

ChrisBD
+1  A: 

There are few reasons that I can say...

  1. Supported by Expression Blend and Expression Design. They are more powerful and easy to use than Visual Studio design pane.
  2. Its easier to change the Xaml manually for some simple things like say

    < Rectangle Margin=20,20,10,0" VerticalAlignment="Center" Fill="Red" />

  3. Xaml is easier to understand for a designer than C# code.

  4. Can easily separate design view (XAML) and code. Its not so obvious while using designer.cs
Tanmoy