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

Question: ResourceDictionary and Styles like WPF #3614

Closed
mbedded opened this issue Feb 26, 2020 · 3 comments
Closed

Question: ResourceDictionary and Styles like WPF #3614

mbedded opened this issue Feb 26, 2020 · 3 comments

Comments

@mbedded
Copy link

mbedded commented Feb 26, 2020

Hello,

as first thank you very much for your good work to provide a WPF-Like Framework to create cross-plattform applications. So far it works very good on Linux even if there are some minor issues.

I would like to know if there is something like "WPF-Like styling" planned in the future. In classic WPF you write something like

<Style x:Key="MyKey" TargetType="{x:Type Button}">
  <Setter Property="Foreground" Value="Red" />
</Style>

<Button Style="{DynamicResource MyKey}" />

Those styles can be written in separate ResourceDictionaries so you have a some files for your styles (e.g. ButtonStyles.xaml, TextboxStyles.xaml...)

Currently the documentation says that "Styles like WPF are not supported".

Note that unlike WPF/UWP, styles will have no effect if they're added to a control or application ResourceDictionary. This is because the order that styles are defined in Avalonia is important and ResourceDictionary is an unsorted dictionary.
(https://avaloniaui.net/docs/styles/styles)

I see that some people like the CSS-Like styling. I'm just wondering why a different kind of "use styles" was added because there is already a way to style your application in WPF with good documentation. Furthermore i think that the "WPF way" is more intuitive for people which switched from Windows to Linux or Mac, because the tooling/syntax is already known.
Do you plan to support Styles and ResourceDictionaries in a later version or do you want to support CSS-Styling only? Is there some ETA for a basic-support of WPF-Styles? I know this project has no 1.x version yet but i think you're on a very good way :)

If there is already a issue for this particular question feel free to close this ticket. The references (see below) didn't helped me.

Thank you very much for your help and keep up the good work :)

References:

@kekekeks
Copy link
Member

The plan is to implement #2769 somewhere this year.

However those will not be resolved from resource dictionaries automatically for x:Key="{x:Type Button"}. You'll have to do something like

<Style Selector="Button">
    <Setter Property="ControlTheme" Value="{DynamicResource ButtonStyleResourceKey}" />
</Style>

or <Button ControlTheme="{DynamicResource ButtonStyleResourceKey}"/>

We still haven't decided on "ControlTheme" name and might use "Style" instead.

@grokys
Copy link
Member

grokys commented Feb 27, 2020

I see that some people like the CSS-Like styling. I'm just wondering why a different kind of "use styles" was added because there is already a way to style your application in WPF with good documentation.

To answer this question: because when I started Avalonia, it was for fun and I didn't really expect it to get to the state where people are wanting to port WPF applications to it ;)

@mbedded
Copy link
Author

mbedded commented Feb 27, 2020

Thank you both for clarification. It sounds to me that I have to stick with this "Selector" attribute and CSS-like-definitions for styling (when I understood everything correctly).
It feels different for me because I develop WPF application since some years. On the other hand WPF != AvaloniaUI :)

Thank you for clarification

@mbedded mbedded closed this as completed Feb 27, 2020
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

No branches or pull requests

3 participants