Tuesday, April 28, 2009

Windows Presentation Foundation - a fresh breeze in user interface programming

It has been very refreshing to get used to write user interfaces in a markup-language (XAML) and program the behind-the-scenes behaviour in another file (C# code).

I am experimenting with the following style, which has not been possible with most of the previous user interface technologies:
1. In the C# code, expose all the data required by user interface as dependency properties. In addition, avoid setting properties of the user interface controls directly.
2. In the XAML file, bind the properties of the controls to the dependency properties declared in the C# code.
3. Hint: style triggers and converters can be used to implement dynamic user interface.

So far it seems to work fine. The C# code is pretty much independent of the user interface and one can extend the user interface without tinkering with the code.