ChildWindow Not Respecting Custom Global Style

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
fangeles
Posts: 43
Joined: Wed Jan 16, 2019 12:48 am

ChildWindow Not Respecting Custom Global Style

Postby fangeles » Tue Apr 14, 2020 10:45 am

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

JS-Support @Userware
Site Admin
Posts: 1120
Joined: Tue Apr 08, 2014 3:42 pm

Re: ChildWindow Not Respecting Custom Global Style

Postby JS-Support @Userware » Mon May 11, 2020 11:30 pm

Hi Fernan,
Thanks for reporting this. We are going to look into it. We'll keep you updated.
Thanks

JS-Support @Userware
Site Admin
Posts: 1120
Joined: Tue Apr 08, 2014 3:42 pm

Re: ChildWindow Not Respecting Custom Global Style

Postby JS-Support @Userware » Fri May 15, 2020 12:08 pm

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


Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests