Josh Smith: Thinking in WPF

May 8, 2007 at 5:46 pm (Guidelines, WPF)

I admire Josh Smith and his WPF knowledge. I’ve learned a lot about WPF from reading his articles, posts, and samples. Recently, Josh wrote 10 tips which he refers to as rules of thumb when thinking in WPF. Read his post to get the details on each of the tips below.

  1. Do not hesitate to write code.
  2. Keep your XAML dumb.
  3. Keep visual resources out of value converters.
  4. Create modular value converters.
  5. Expose functionality as services, not subclasses.
  6. Think thrice before creating a custom control.
  7. Do not micromanage, let panels do the work.
  8. Carefully consider where to put resources.
  9. Strive for elegance, not eye candy.
  10. Avoid being a Blender.

As a creative developer, I have to disagree with tips 1, 2, and 10. With the power of triggers, transforms, control templates, and databinding, I like to make my XAML smart and write code only when it’s necessary. While it’s helpful to know how to perform functionality in code, it can be more beneficial to do it in XAML. A designer would have a hard time modifying the design if everything was done programmatic. Also functionality from procedural code cannot be changed in Expression Blend. Chris Idzerda has more details in his post Prefer descriptive code (e.g. XAML) to procedural code (e.g. C#). Funny enough, Chris’ WPF mantra is “don’t write code”.

Post a Comment