I need to access a TintedResourceDictionary via XAML.
To be frank, I had a working solution until the last update, but I didn't grasp why it even worked at all.
I used ThemeManager.SetTheme(nestedDockSite, m_ThemeName) and could access the tinted Brushes from anywhere inside the Page Control where the nestedDockSite is in. From my understanding, that shouldn't even be possible, as the TintedResourceDictionary is merged in the resources of the DockSite, so neighboring elements shouldn't be able to get access it.
However, it did what I wanted, which is not the case anymore. My last try was to merge the TintedDictionary directly in the parent container. This works for the DockSite, but other child elements besides the DockSite still accesses the resources from the current theme.
This sample XAML clarifies what I want to (re)accomplish:And this is my last try ( commented lines are from the previous, working version)
I thought this must be foolproof, but in this case, the resources are still taken from the current theme (besides the DockSite).
To be frank, I had a working solution until the last update, but I didn't grasp why it even worked at all.
I used ThemeManager.SetTheme(nestedDockSite, m_ThemeName) and could access the tinted Brushes from anywhere inside the Page Control where the nestedDockSite is in. From my understanding, that shouldn't even be possible, as the TintedResourceDictionary is merged in the resources of the DockSite, so neighboring elements shouldn't be able to get access it.
However, it did what I wanted, which is not the case anymore. My last try was to merge the TintedDictionary directly in the parent container. This works for the DockSite, but other child elements besides the DockSite still accesses the resources from the current theme.
This sample XAML clarifies what I want to (re)accomplish:
<Page x:Name="Page">
<StackPanel>
<docking:DockSite x:Name="NestedDockSite"/>
<Rectangle Fill={DynamicResource {x:Static themes:DockingCommonDictionary.ToolWindowContainerTitleBarBackgroundInactiveBrushKey}}/>
</StackPanel>
<Page>
if (!ThemeManager.IsThemeRegistered(m_ThemeName)
&& !string.IsNullOrEmpty(ThemeManager.CurrentTheme)
&& !string.IsNullOrEmpty(DockingCommonDictionary.GroupName))
{
ResourceDictionary _dockingResourceDictionary = ThemeManager.GetResourceDictionary(ThemeManager.CurrentTheme, DockingCommonDictionary.GroupName);
TintedResourceDictionary _tintedDictionary = new TintedResourceDictionary(_dockingResourceDictionary, this.TabTintColor);
//ThemeManager.Register(m_ThemeName, DockingCommonDictionary.GroupName, _tintedDictionary);
this.Frame.LoadCompleted += new LoadCompletedEventHandler((object sender, NavigationEventArgs e) =>
{
//ThemeManager.SetTheme((DependencyObject)this.Page.NestedDockSite, m_ThemeName);
this.Page.Resources.MergedDictionaries.Add(_tintedDictionary);
});
}