Reverse Engineering the Default Styles

Just saw a post from Karstenabout reverse engineering the default Avalon, err WPF control styles. This technique for digging into the styles is clever (and useful), but has a couple of drawbacks.

Theme-specific Resources

First, keep in mind that WPF gets the default control styles from a default resource dictionary associated with the current theme. You can see the assemblies that contain these--they'll be in the same directory as PresentationFramework.dll (and named something like PresentationFramework. Luna.dll). Here's the imporant part: control styles in that resource dictionary may depend on other resources defined in that resource dictionary, and there is no guarantee that these resources will exist accross all themes.

This means that you can't take a dependency on these resources. We see people doing this from time to time and it has the potential to break your app when run under a different theme. We're looking into ways of further obfuscating these, but you will definitely uncover them using the technique that Karsten described.

Overly Complex Styles

Second, the default styles were built to look just like the system controls. This introduces a certain amount of complexity into the styles that might obscure what's really going on. At first glance, it can be hard to know which parts of the style are important. To familiarize yourself with the fundamentals of control styling, you may have better luck with the Simple Styles.



Loading... Show