Page 1 of 1

ChildWindow Not Respecting Custom Global Style

Posted: Tue Apr 14, 2020 10:45 am
by fangeles
Hi,

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.
Example usage:

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.
Example usage:

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.
Example usage:

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

Re: ChildWindow Not Respecting Custom Global Style

Posted: Mon May 11, 2020 11:30 pm
by JS-Support @Userware
Hi Fernan,
Thanks for reporting this. We are going to look into it. We'll keep you updated.
Thanks

Re: ChildWindow Not Respecting Custom Global Style

Posted: Fri May 15, 2020 12:08 pm
by JS-Support @Userware
We have looked into these issues.

- The behavior of (1) is correct (same in Silverlight, WPF, and UWP), because implicit styles do not automatically apply on inherited classes, and your "UserMaintenance_UserDetail" is inherited from ChildWindow (see for example the "first issue" at: https://stackoverflow.com/questions/646 ... g-problems )

- The behavior of (2.b) is incorrect. We have just fixed it. Please expect the fix in the very next release on NuGet.

- The behavior of (3) is correct.

Thanks a lot