Reputation: 1264
I have built a WPF config-tool with mahapps.metro (version 1.5!) that lets the user configure my other apps. On one of the views I let the user define the styles. To make it more easy to decide which style fits, I created a control that looks like the other apps in miniature. The idea is to set the defined style to this preview.
So, is it possible to change the theme for a single UserControl dynamical? All I have found is the ThemeManager class, but with that I change the theme for the complete app or the complete current window and not only for the one control within my current window:
ThemeManager.ChangeAppStyle(Application.Current, …)
I am open for other (practical) solutions. But it has to be part of same window, to have a dialog or preview popup is no acceptable solution.
Upvotes: 1
Views: 454
Reputation: 19296
ThemeManager.ChangeAppStyle
can accept Window
as the first parameter. So instead of using UserControl
you can make Window
and in this window, you can show a new style:
public partial class Window1 : MetroWindow
{
public Window1()
{
InitializeComponent();
ThemeManager.ChangeAppStyle(this,
ThemeManager.GetAccent("Orange"),
ThemeManager.GetAppTheme("BaseLight"));
}
}
Upvotes: 0