PETZOLD BOOK BLOG

Charles Petzold on writing books, reading books, and exercising the internal UTM


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

My Article on Templates in MSDN Magazine

December 13, 2006
Roscoe, NY

The January 2007 issue of MSDN Magazine has just gone on line here, and back in the Columns section you can find a new column named Foundations, which I'm very proud has been inaugurated with an article on WPF templates I wrote.

As you may know, all controls included in the Windows Presentation Foundation have a default visual appearance defined by a template. These templates can be replaced with ones written by you, the WPF application programmer. Templates can be written in code, but are much simpler and straighforward in XAML. In this article, I focus mostly on control templates for the ProgressBar, ScrollBar, and Slider controls.

All the source code in this article is in the form of standalone XAML files, and most of them can be launched under Windows Vista (or Windows XP with the .NET 3.0 runtime installed) where they will run in Internet Explorer. The exception is the SpringLoadedScrollBar.xaml file, which uses bitmap effects that inexplicably play outside the sandbox. You'll have to run that one in XamlPad or XamlCruncher or a similar program.

If you are skeptical about the utility of 3D graphics in a user interface like Windows, you might want to check out the Slider3D.xaml file that concludes the article. I tried to make this template look like a potentiometer on an audio mixing board, and I use the 3D facilities of WPF to change the perspective as the slider moves up and down. It's a fairly subtle effect, but I happen to think it's quite adorable.

You can find additional background on different types of templates in Chapter 25 of my book Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation. A blog entry from the summer uses templates to implement a binary adder entirely in XAML.

This new Foundations column will alternate among columns on the WPF, WCF, and WF. I'll be writing at least three more WPF articles on a quarterly basis. (Actually two more: This morning I submitted my column for the April issue a whole two days ahead of deadline.) If you have a column idea, let me know at cp@charlespetzold.com. (Use a Subject line like "MSDN Article Suggestion" so your email doesn't look like spam.) There are three criteria: (1) The article has to be about the WPF; (2) It can't be something I've already covered in my book; and (3) I have to be able to do it in 4,000 words.


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold
www.charlespetzold.com