Replacing merged dictionaries resources used internally by components of Gantt Chart Light Library

Sometimes when you use components from Gantt Chart Light Library you may want to replace some resources used internally by the components, together with replacing component styles and templates using our Generic.xaml default definitions which, by the way, you can download from our Web site, both for Gantt Chart controls and for PERT Chart components (note that these links are for WPF output platform).

For example, if you want to modify the showing duration for the item ToolTip which is injected to TaskPresenter objects as part of the TaskPresenterContentDataTemplate resource.

Trying to redefine this resource only, using the same key, won't work, although you could redefine the entire style for TaskPresenter objects. That's because by design, we load generic resources to MergedDictionaries of component's Resources collections, and they are internally found before your custom overriding resource.

To resolve issues of this type, you can try removing or replacing the original resource from the MergedDictionaries host at runtime:

var originalResourceDictionary = component.Resources.MergedDictionaries[0];
originalResourceDictionary.Remove(key); // e.g. "TaskPresenterContentDataTemplate"
// Optionally add a custom resource instead, to the original dictionary, using the same key.
originalResourceDictionary.Add(key, customResource);