I have followed the guidelines to customize the look of the ChildWindow here:
http://cshtml5.com/links/styles-and-templates.aspx#ChildWindow
But I removed the x:Key attribute to become global style. I inserted it inside App.xaml
There are 3 scenarios I encountered:
1. When I create a custom ChildWindow Control (ex: UserMaintenance_UserDetail.xaml) and I have this global style of ChildWindow (without the x:Key attribute):
- a. The childwindow styles (such as the chrome) does not apply to the created custom ChildWindow control.
b. Other styles (such as button, textbox styles etc.) are applied to the controls inside the created custom ChildWindow control.
Code: Select all
<ChildWindow x:Class="App1.Pages.UserMaintenance_UserDetail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="300" Height="590"
Title="User Information"
xmlns:local="App1.Pages"
FontSize="14">
//c#
UserMaintenance_UserDetail det = new UserMaintenance_UserDetail();
det.Show();
2. When I create a custom ChildWindow Control (ex: UserMaintenance_UserDetail.xaml) and I have this explicit style of ChildWindow (with x:Key attribute):
- a. The childwindow styles (such as the chrome) was applied to the created custom ChildWindow control.
b. Other styles (such as button, textbox styles etc.) does not apply to the controls inside the created custom ChildWindow control.
Code: Select all
<ChildWindow x:Class="App1.Pages.UserMaintenance_UserDetail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="300" Height="590"
Title="User Information"
Style="{StaticResource ChildWindowStyle1}"
xmlns:local="App1.Pages"
FontSize="14">
//c#
UserMaintenance_UserDetail det = new UserMaintenance_UserDetail();
det.Show();
3. When I create the ChildWindow programatically and I have this global style of ChildWindow (without the x:Key attribute):
- a. The childwindow styles (such as the chrome) was applied to the ChildWindow created on c# code.
b. As well as other styles (such as button, textbox styles etc.) also applied to the controls inside the ChildWindow control.
Code: Select all
ChildWindow cw = new ChildWindow();
cw.Show();
If I have an implicit childwindow style and created the childwindow via code, the result is the same to scenario #2.
Example usage:
Code: Select all
ChildWindow cw = new ChildWindow();
Style style = Application.Current.Resources["ChildWindowStyle1"] as Style;
cw.Style = style;
cw.Show();
Is it a bug? Or I am doing it wrong?
Hoping for your response.
Thanks.
Fernan