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.
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).
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.
There are few reasons that I can say...
- Supported by Expression Blend and Expression Design. They are more powerful and easy to use than Visual Studio design pane.
Its easier to change the Xaml manually for some simple things like say
< Rectangle Margin=20,20,10,0" VerticalAlignment="Center" Fill="Red" />
Xaml is easier to understand for a designer than C# code.
- Can easily separate design view (XAML) and code. Its not so obvious while using designer.cs