Silverlight Toolkit - ChildWindow with Theme
From a silverlig开发者_StackOverflow社区ht forum page I found, I was under the impression that a ChildWindow created in the code behind would pick up the theme of the rest of the page; it's only when you inherit from ChildWindow that this no longer is the case.
For some reason though this is not happening for me. Here is my theme element:
<wp:Theme x:Name="ThemeContainer" ThemeUri="/System.Windows.Controls.Theming.BubbleCreme;component/Theme.xaml">
And here's the event handler for a button that I'm using to try to create a ChildWindow. The window pops up, but does not have any theme applied:
private void Button_Click(object sender, RoutedEventArgs e) {
ChildWindow cw = new ChildWindow() { Height = 250, Width = 200 };
cw.Show();
}
Is there any way to get this to work?
You'll have to set your desired global theme in the App.xaml and declare it as the Application's theme:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyApp"
xmlns:thm="MyThemeNamespace"
thm:MyTheme.IsApplicationTheme="True"
>
<Application.Resources>
</Application.Resources>
</Application>
To set the application theme dynamically, you can try the static
Theme.SetApplicationThemeUri(myApp, myThemeUri);
精彩评论