While reading Chris Sell's and Ian Griffith's Programming Windows
Presentation Foundation
book, I ran across the following tidbit on chapter 9
on custom controls: "One of the main reasons for writing custom controls in
older user interface technologies is to modify the appereance of a control, but
as we've seen in earlier chapters, the content model and templates mean this is
often unnecessary."

From what little I've experienced of WPF, the whole templating mechanism
seems extremely powerful, particularly given the content model for UI Elements
and the layout mechanism. Certainly, very impressive things can be achieved this
way. That said, it does seem the whole templating mechanism can be just as
easily abused (just like everything else in every other technology). So, where
does the line get drawn between templating and creating new custom controls?
Obviously, the second option takes more work (or so it seems to me, at this
time), while the first can be more convenient.

Thing is, in my experience working with other smart-client technologies
(WinForms, MFC, Win32), I found myself creating custom controls not just because
it was the only possibility to affect behavior or custom draw a control (it
isn't), but because it really helped make the code more modular and mantainable
and make it self-contained (which helps reusability a lot, by the way). So, when
I look at the templating mechanism in WPF, I find myself thinking that, while
very cool and powerful, it could easily turn into a mantainance nightmare.
In other words, I find myself asking "How is this different from, say, handling
the Paint event for a child control in a Windows Forms and doing custom drawing
there?" (from a code estructure point of view). At least from my little
knowledge of WPF, I'd dread hundreds-of-lines XAML files with tens of
templates and resources, just as much as I'd dread the corresponding windows
forms code with hundreds of lines of embedded presentation, drawing and business

I've been pondering about this for a while, and would love to hear the
opinion of those of you that have been doing real-world WPF applications out
there on the topic of reusability, templates and custom controls on WPF. Please,
please convince me I'm wrong ;-)

Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.