Tweets by @Actipro
Please take some time to learn more about us and our product offerings.
We're currently ramping up for the Actipro WPF Studio v3.5 release, and I wanted to discuss some of the new framework features that we've built into the Shared Library for this release.
As a side note, we have an exciting new WPF product that will be part of v3.5 and all WPF Studio customers will get it for free upon release. But more on that in a later blog post.
As we started adding more controls to WPF Studio that have numerous themes, we recognized the fact that we really need to have a common themes framework that supports both the native WPF system theme switching capabilities, along with an optional easy way to change the entire theme of an application with a single line of code.
Take Office for example... they offer three built-in themes: blue, silver, and black. Our goal with the design of our theme framework was to be able to say in one line of code, change all Actipro controls (and any other controls that use this framework) to look right under a user-specified theme.
That's right, the framework is fully extensible so that when you use WPF Studio with your WPF applications, and you've defined your own custom controls, you'll be able to wire up multiple themes of your own custom control to our theme manager and have the theme automatically change when you set the application's theme.
Changing a theme is as simple as a line of code like this:
ThemeManager.CurrentTheme = "Office2007Blue";
That line of code will automatically change any control's theme that is registered with ThemeManager to use resources for the specified theme name.
ThemeManager also defines an attached Theme property that can be set on any control. So say you only want to change themes on a particular UserControl and make any of its contents use a Windows XP Blue theme, simply set the ThemeManager.ThemeProperty value on the UserControl to "LunaNormalColor" and voila, the child controls update.
Everything in the themes framework is built upon the base resource dictionary design in WPF. Essentially ThemeManager maintains a catalog of what resource dictionaries provide what themes for what controls. When you change a theme, it unloads any previously-loaded dictionaries and loads any appropriate new ones.
As mentioned, Actipro controls that support multiple themes will have this functionality built-in, but you can also register themes for your own controls and have them change themes right along side of Actipro's controls for a consistent user interface.
Our theme framework also supports the tinting of any theme or portion of a theme towards a certain color. This means that you can take a built-in theme like the Office 2007 silver theme, and make it a red one instead. Various groups of brushes and pens can be defined as belonging to tint groups, allowing you to change certain portions of a theme's resources to different colors.
A new object serialization framework will appear in v3.5.
A class named XamlSerializer provides numerous methods for saving any object to XAML with one line of code and reloading the object later, again with a single line of code. You can persist to a string, Stream, file, or XmlWriter.
We also started encountering a pattern where hierarchies of objects need to be persisted to XML. This is most commonly used when persisting end user layout changes for controls (like docking window layouts, etc.).
Therefore we came up with a framework for easily building serializable object hierarchies that harnesses the .NET XmlSerializer at its core but provides a wrapper around that functionality with many useful features.
For instance, the framework also can serialize to a string, Stream, file, or XmlWriter with one line of code.
An added benefit of the framework is that you can provide a delegate that is called whenever an object in the object hierarchy is serialized. This allows you to insert custom data into the serialized data at any location. Likewise, you can read this data back in by providing another delegate at load time.
We envision this framework being used in many future WPF products.
Finally, we came up with a good way of storing and accessing string resources for our products. Any string that is displayed in the user interface for our controls will now be located in normal .NET string resources.
We provide an SR (string resource) class in each product that has string resources, which can retrieve a named string resource programmatically. And we include an SRName enumeration containing the names of all string resources in the product.
On top of that, the SR class has a number of methods for completely customizing the string resources by changing specific string resource values to custom strings. This will be most commonly used for localization.
The SR class returns the resolved string resource value between the customizations and the defaults.
To make things even better we also have make a markup extension that can be used in XAML. Simply call the markup extension and pass it the name of the string resource to retrieve. Its return value will be the resolved value of the string resource. We now use this throughout our control templates.
These are just some of the new features you'll find in WPF Studio v3.5 when it is released soon.
March 5, 2008 at 12:50
I think you're definitely moving in the right direction with Themes, animations, transitions, etc. I enjoy using these features, but man do I despise trying to code them myself! My brain just doesn't think that way. I think the market for WPF themes, animations, transitions is going to be huge. Keep up the great work.