Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window gets :is(Control) style applied twice #8549

Closed
grokys opened this issue Jul 20, 2022 · 1 comment · Fixed by #9411
Closed

Window gets :is(Control) style applied twice #8549

grokys opened this issue Jul 20, 2022 · 1 comment · Fixed by #9411
Labels

Comments

@grokys
Copy link
Member

grokys commented Jul 20, 2022

Describe the bug

Windows get the :is(Control) style applied twice, as can be seen in DevTools:

image

To Reproduce
Steps to reproduce the behavior:

  1. Run an Avalonia application
  2. Open DevTools
  3. Notice that the style is applied twice

Desktop (please complete the following information):

  • OS: All
  • Version: master and stable
@grokys grokys added the bug label Jul 20, 2022
@grokys grokys changed the title Window gets :is(Control) style applied twice Window gets :is(Control) style applied twice Jul 20, 2022
@grokys grokys changed the title Window gets :is(Control) style applied twice Window gets :is(Control) style applied twice Jul 20, 2022
@grokys
Copy link
Member Author

grokys commented Jul 20, 2022

Caused by this line in TopLevel - added in 2015!

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/TopLevel.cs#L185

This causes styling to be applied as soon as the TopLevel is constructed, but it doesn't go via StyledElement.ApplyStyles, so that system isn't aware of the styling being applied, and so re-applies it on the first layout pass.

I quickly tried to just remove this line, but a bunch of controls/tests rely on the styling being applied after construction.

grokys added a commit that referenced this issue Jul 21, 2022
grokys added a commit that referenced this issue Nov 10, 2022
Applying styling in the constructor isn't a good idea as demonstrated by #8549..

Instead apply styling when showing a window, or if it's needed call `ApplyStyling` manually, e.g. in unit tests.

Fixes #8549
grokys added a commit that referenced this issue Nov 21, 2022
Applying styling in the constructor isn't a good idea as demonstrated by #8549..

Instead apply styling when showing a window, or if it's needed call `ApplyStyling` manually, e.g. in unit tests.

Fixes #8549
grokys added a commit that referenced this issue Nov 21, 2022
Applying styling in the constructor isn't a good idea as demonstrated by #8549..

Instead apply styling when showing a window, or if it's needed call `ApplyStyling` manually, e.g. in unit tests.

Fixes #8549
grokys added a commit that referenced this issue Nov 21, 2022
Applying styling in the constructor isn't a good idea as demonstrated by #8549..

Instead apply styling when showing a window, or if it's needed call `ApplyStyling` manually, e.g. in unit tests.

Fixes #8549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant