Charles Petzold



The Book's Gotta Have It

January 16, 2005
A feels-like-3° NYC

892 pages into the popular text The Art of Electronics, 2nd edition, by Paul Horowitz and Winfield Hill, the authors finally get around to discussing a certain topic. A paragraph begins:

And then the paragraph concludes:

I often think about that passage when working on a book, and particularly last week, when I retitled a "Custom Controls" chapter to "Custom Elements." The question reformulated in my mind is:

That means I got deep into MeasureOverride and ArrangeOverride. About 44 classes in the WPF override the first method, and about 39 classes the second method, so it's obvious to me that these methods are very important in understanding automatic sizing and layout. But they're not trivial. Although I have several sample classes that illustrate inheriting from FrameworkElement and Control — including a UniformGrid-like panel and a color-selection control like the one in MS Word — my attempts to reverse-engineer Measure and Arrange have yielded unsatisfactory results (so far).

"Custom Elements" is one of three "conceptual chapters" that appear in the middle of Part 1 of the book. The other two are "Dependency Properties" and "Routed Input Events," both of which are necessary preliminaries to inheriting from FrameworkElement.