Charles Petzold – Always the Best Examples
Article Quote of Interest
Charles Petzold writes brilliant software. He's an icon – well, not literally – in the MS Developer world. His seminal book, Programming Windows, 1st edition (Microsoft Press, 1988; 852 pages), sets the bar for what a great developer books should be.
I'm committing to reading some of his articles that teach the basics of WPF. Actually, some of it is quite complex and it is explained better than many books. I've always liked buying books from one or more authors, because it provides continuity. But so does reading the work of one great writer, Charles Petzold.
Foundations - Using Templates to Customize WPF Controls
I'm picking up some interesting quotes, which I'll setup with questions:
Why does previous control authoring get so painful?
Previous versions of control development was "often resistant to customization due to deeply inaccessible code that links the visuals of the control with its functionality. This code is vital to the control so it must be either completely accepted or completely bypassed and replaced.[1]"
What is more difficult to learn? Templates or Styles?
"Presentation Foundation styles (which are often confused with templates), but templates needed time to sink in.[1]"
What is special about templates? What can they do? What are they used for?
"Every predefined control in the Windows Presentation Foundation that has a visual appearance also has a template that entirely defines that appearance. This template is an object of type ControlTemplate that is set to the Template property defined by the Control class."
Why does a developer care about "Template?"
Allows others to easily change the UI of your control. They just define their own "Template"
"you can replace that default template with one of your own design.[1]"
Do I lose keyboard and mouse handling?
No. "You retain the basic functionality of the control-including all the keyboard and mouse handling-but you can give it an entirely different look. This is what is meant when Windows Presentation Foundation controls are described (rather inelegantly) as 'lookless.' A control has a default look, but this look is not intrinsic to the inner workings of the control."
[1]
Url
https://msdn.microsoft.com/en-us/magazine/cc163497.aspx
Reference
Foundations
Using Templates to Customize WPF Controls
MSDN Magazine – January 2007
Charles Petzold