Theming Multiple Infragistics WPF Controls At Runtime

Kiril Matev / Friday, March 11, 2011

All too often you’d like to give your users a way to theme your applications at runtime. Theming entire screens containing multiple Infragistics NetAdvantage WPF LIne of Business controls is easy to implement and could be a valuable addition to your applications. It involves setting the value of the Theme property to the currently set theme on the application level.

The Approach

For all Infragistics WPF Line of Business controls that you’d like to theme, you need to set their Theme property to “[Current]”. This will bind their Theme property to the ThemeManager CurrentTheme property.

You can then set the CurrentTheme property of the ThemeManager to change the theme applied to all controls in the application. For example the statement below will cause all Infragistics WPF Line of Business controls to be themed using the Office 2007 Black theme:

ThemeManager.CurrentTheme=”Office2k7Black”;

In the sample, we control the theme used using a DropDown control, which is populated with the list of themes available in the ThemeManager using its GetThemes method.

Summary

Allowing your end-users to theme your application increases its usability as it enables your users to set the appearance they’re most comfortable with. As you can see, with a very small number of changes you can enable that and deliver a flexible theming in your applications using Infragistics WPF Line of Business controls.

If you have any questions, please email me at kmatev@infragistics.com