SystemParameters
It takes time getting used to a new framework like WPF. The other day I was looking for system information similar to what the System.Windows.Forms.SystemInformation static class provided in Windows Forms. It took a little looking, but the equivalent WPF object is the System.Windows.SystemParameters class. It has all the same goodness that you would expect, like ScrollWidth and MenuBarHeight and some new things like IsTabletPC. I should also point out that there are similar classes for fonts and colors called System.Windows.SystemFonts and System.Windows.SystemColors respectively.
What I thought was creative about the new classes is that for each static property there is an equivalent resource key. This makes it easy to bind to those values as you would any other dynamic resource. That in turn makes it easy to use in XAML and the values dynamically update when the system environment changes.
Here’s an example:
<Style x:Key="SimpleParam" TargetType="{x:Type Button}"> <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.CaptionHeightKey}}"/> <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.IconGridWidthKey}}"/> </Style>
It couldn’t be easier.