Docking & MDI Themes not working

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 9 years ago by Christian Lutze
Version: 15.1.0621
Avatar

Hello,

i'm trying to change the theme from my docking window at runtime.

This is my code to change the Theme:

ThemeManager.BeginUpdate();
try
{
ThemeManager.SetAreNativeThemesEnabled(this, true);
ThemeManager.SetTheme(this, ThemeName.HighContrast.ToString());

ThemeManager.ApplyTheme(this);
}
finally
{
ThemeManager.EndUpdate();
}

Unfortunally it's not working. I tried ActiPro Version 2014.2 AND 2015.1.

 

Can somebody help me? I thing it's only a little misstake in my code.

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Can you tell me why you're trying to only update a single docking window with a different theme?  I'm not sure I would recommend that sort of thing since the docking window could be docked around various places in the layout and its contents would appear different.

Is this in a floating window that you are not seeing the update?  Please describe the scenario in some more detail so we can fully understand the problem.  Thanks!


Actipro Software Support

Posted 9 years ago by Christian Lutze
Avatar

Ok maybe my description was a little bit bad.

I added to my Visual Studio project a Docking & Tabbed MDI Window.

This is working fine. 

Now i tried to change the theme from this window, but it's not working for me.

I guess i do a misstake. 

How can i easy change the theme for all my windows and the whole project?

 

I call this in the constructor of the window:

 

ThemeManager.BeginUpdate();
try
{
ThemeManager.SetAreNativeThemesEnabled(this, true);
ThemeManager.SetTheme(this, ThemeName.HighContrast.ToString());

ThemeManager.ApplyTheme(this);
}
finally
{
ThemeManager.EndUpdate();
}

 

And this is the generated XAML code:

<Window x:Class="CANape2015Templates.DockingTabbedMdiWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
Title="DockingTabbedMdiWindow1" Width="620" Height="420">

<!-- TODO: Associate an image with the DocumentWindow and ToolWindows below by setting ImageSource -->

<Grid>
<!-- DockSite -->
<docking:DockSite x:Name="dockSite">

<!-- TODO: Add additional tool windows that will be close initially -->
<docking:DockSite.ToolWindows>
<docking:ToolWindow x:Name="initiallyClosedToolWindow" Title="Initially-Closed">
<TextBlock Margin="3" Text="This tool window was initially closed." TextWrapping="Wrap" />
</docking:ToolWindow>
</docking:DockSite.ToolWindows>

<!-- TODO: Add additional tool windows that should be docked on the left, but in the auto-hide state -->
<!-- NOTE: Use AutoHideTopContainers, AutoHideRightContainers, and AutoHideBottomContainers to dock to other sides -->
<docking:DockSite.AutoHideLeftContainers>
<docking:ToolWindowContainer>
<docking:ToolWindow x:Name="autoHideLeft" Title="Auto Hide Left">
<TextBlock Margin="3" Text="This tool window is in the auto-hide state on the left side."
TextWrapping="Wrap" />
</docking:ToolWindow>
</docking:ToolWindowContainer>
</docking:DockSite.AutoHideLeftContainers>

<!-- NOTE: Split containers can contain two elements, which are typically ToolWindowContainers (with 1 or more tool windows)
and one (and only one) Workspace -->
<docking:SplitContainer>

<docking:SplitContainer Orientation="Vertical">

<!-- NOTE: The Workspace holds the main content, which is typically TabbedMdiHost or StandardMdiHost -->
<docking:Workspace>

<docking:TabbedMdiHost x:Name="tabbedMdiHost">
<docking:TabbedMdiContainer>

<!-- TODO: Add additional document or tool windows -->
<docking:DocumentWindow Title="Document1.txt" Description="Text document" FileName="Document1.rtf">
<TextBox BorderThickness="0" TextWrapping="Wrap" Text="The first document." />
</docking:DocumentWindow>

<docking:DocumentWindow Title="Document2.txt" Description="Text document" FileName="Document2.rtf">
<TextBox BorderThickness="0" TextWrapping="Wrap" Text="The second document." />
</docking:DocumentWindow>

<docking:DocumentWindow x:Name="document3" Title="Document3.txt" Description="Text document"
FileName="Document3.rtf" IsReadOnly="True">
<TextBox BorderThickness="0" TextWrapping="Wrap"
Text="The third document, which is read-only."
IsReadOnly="{Binding ElementName=document3, Path=IsReadOnly}" />
</docking:DocumentWindow>

</docking:TabbedMdiContainer>
</docking:TabbedMdiHost>
</docking:Workspace>

<docking:ToolWindowContainer>
<docking:ToolWindow x:Name="dockedBottom" Title="Docked Bottom">
<TextBlock Margin="3" Text="This tool window is docked below the Workspace."
TextWrapping="Wrap" />
</docking:ToolWindow>
</docking:ToolWindowContainer>

</docking:SplitContainer>

<docking:ToolWindowContainer>
<docking:ToolWindow x:Name="dockedRight" Title="Docked Right">
<TextBlock Margin="3" Text="This tool window is docked to the right of the Workspace."
TextWrapping="Wrap" />
</docking:ToolWindow>
</docking:ToolWindowContainer>

</docking:SplitContainer>

</docking:DockSite>
</Grid>

</Window>

 

Thanks for help.

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Generally, you would do this in your app's OnStartup:

ThemeManager.BeginUpdate();
try {
	// The Office and Metro themes are in separate assemblies and must be registered if you will use them in the application
	ThemesOfficeThemeCatalogRegistrar.Register();
	ThemesMetroThemeCatalogRegistrar.Register();

	// Use the Actipro styles for native WPF controls that look great with Actipro's control products
	ThemeManager.AreNativeThemesEnabled = true;

	// Default the theme to Metro Light
	ThemeManager.CurrentTheme = ThemeName.MetroLight.ToString();
}
finally {
	ThemeManager.EndUpdate();
}

The code there will load the Office and Metro themes and set the current app-wide theme to Metro Light.  Again, this is done in the app's OnStartup.  You could remove the Office or Metro registrations if you don't use either of those themes.  And you could change the theme name set to the CurrentTheme property if another theme is more appropriate for you.

Then at run-time later on, if you wish to change the app-wide theme to something else, simply set the ThemeManager.CurrentTheme property to a new value (a single line of code), and that's all you have to do.


Actipro Software Support

Posted 9 years ago by Christian Lutze
Avatar

Thank you so much for the good and fast support.

Now its working very well. It was only the registration from the themes missing.

I hav only one last question.

Is it possible to change the accent color from the metro light theme. If i click on a tabbed mdi window the tab is highlight blue.

How can i change this color e.g. to green?

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Christian,

Yes, our theme system defines hundreds of brush, Thickness, etc. resources that you can fully override in your app's Resources. For instance you could change this one:

<SolidColorBrush x:Key="{x:Static themes:AssetResourceKeys.TabbedMdiContainerTabItemBackgroundActiveFocusedBrushKey}" Color="Green" />

There are other TabbedMdi* brush resources that would also need to be altered to match.

When running our Sample Browser app, click Tools / Theme Browser and you can browse through all of the default brushes to know which ones to change.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.