CommonDictionary and DataGrid library throw error

Ribbon for WPF Forum

Posted 13 years ago by Mick
Version: 11.1.0542
Platform: .NET 4.0
Environment: Windows Vista (32-bit)
When using a dictionary of brushes (for example, RibbonCommonDictionary and DockingCommonDictionary):

1) Include all Actipro libraries in your sample project. (ActiproSoftware.DataGrid.Contrib.Wpf351.dll seems to be the offending one though):

2) XAML:

            <Style TargetType="{x:Type Rectangle}">
                <Setter Property="Fill" Value="{DynamicResource {x:Static themes:RibbonCommonDictionary.ApplicationButtonForegroundNormalBrushKey}}" />
3) Code behind:

using System;
using System.Windows;
using ActiproSoftware.Windows.Themes;

namespace Themes
    public partial class MainWindow : Window
        public MainWindow()
            Loaded += MainWindow_Loaded;

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
            ThemeManager.CurrentTheme = CommonThemeName.Office2010Black.ToString();
4) Start the project: I get an error about the ResourceDictionary.DeferrableContent throwing an exception.

Note: If you run the same code without a reference to the DataGrid library, everything works fine (and any brushes that you reference will be used correctly).
Is there a way to

A) use a brush dictionary
B) switch themes dynamically

while including the DataGrid project on version 11.1.542?

Thank you

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mick,

In general, you should set the CurrentTheme in your application (either the constructor or OnStartup override). Changing the theme causes new Styles/ControlTemplates to be applied, which will ultimately result in the controls to be reloaded. So changing in after the MainWindow has been loaded would at a minimum cause it to load slower.

If you are using .NET 4, then you cannot use the DataGrid.Contrib we ship with our installer. The version we ship is built to target .NET 3.5 SP1, where the Microsoft DataGrid is part of WPF Toolkit. In .NET 4, they merged it into the .NET runtime, so if you try to load our DataGrid.Contrib it will still reference the WPF Toolkit version (and thus fail, due to there being two DataGrids).

Our DataGrid.Contrib project is open sourced at and is ready to be compiled to target the .NET 4 framework.

If that's not your issue, please let us know.

Actipro Software Support

Posted 13 years ago by Mick
Thank you, that makes sense.

Can you suggest a way to make the theme change instant (and not require a restart of the application)?

I'm just looking to mimic Office 2010 where the user can change the theme while running the program and see the changes.

Thank you
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mick,

The CurrentTheme can be set to change the theme during runtime. It's just not recommended to set or initialize it in the Loaded event.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.