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

feat: modernize TemplateControl template #239

Conversation

workgroupengineering
Copy link
Contributor

@workgroupengineering workgroupengineering commented Nov 14, 2023

  • Replace Styles with ResourceDictionary
  • Style Selector whith ControlTheme
  • Add ThemeDictionaries
  • Add ThemeVariantScope in Design.PreviewWith

Depended from AvaloniaUI/Avalonia.Samples#66

Comment on lines 19 to 29
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="MyForegroud" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="MyForegroud" Color="White"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should have this in the templates.
I would rather add a comment with a link to the Avalonia.Samples, where we would have this.

@workgroupengineering workgroupengineering force-pushed the features/modernize_templatedcontrol branch from 9c57e43 to c53b1d0 Compare November 16, 2023 11:40
@workgroupengineering workgroupengineering marked this pull request as ready for review November 16, 2023 11:42
@maxkatz6
Copy link
Member

Can we remove dynamic resources / theme dictionaries at all?
I am all for adding comments with some instructions on how to use control themes and how to define custom colors.
In my opinion, it's not good to add big parts of the code that will end up removed by 99% of the users, as they don't need it.

@maxkatz6
Copy link
Member

<Setter Property="Template">
<ControlTemplate>
<TextBlock Text="Templated Control" />
<TextBlock Text="Templated Control" Foreground="{TemplateBinding Foreground}" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Foreground is here? It's an inherited property. In Avalonia controls we try to avoid redefining this property, where it can be inherited.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an indication for beginners of how it might be done.

Co-authored-by: Max Katz <maxkatz6@outlook.com>
@workgroupengineering workgroupengineering force-pushed the features/modernize_templatedcontrol branch from 1123cb4 to e2028a4 Compare November 30, 2023 09:55
@maxkatz6
Copy link
Member

maxkatz6 commented Dec 5, 2023

I still think Foreground on TextBlock will only confuse users, as it should be inherited in third party libraries.

@maxkatz6
Copy link
Member

maxkatz6 commented Dec 5, 2023

But either way, this PR looks good to me overall, but can only be merged once we drop 0.10 from our templates.
I would say, we can do it with 11.1.

@maxkatz6 maxkatz6 mentioned this pull request Mar 7, 2024
7 tasks
@maxkatz6 maxkatz6 merged commit 9a856eb into AvaloniaUI:master Mar 11, 2024
3 checks passed
@workgroupengineering workgroupengineering deleted the features/modernize_templatedcontrol branch March 12, 2024 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants