Replies: 14 comments 19 replies
-
I don't see this functionality on the roadmap and I know you are working to finish up 0.9 at the moment. Can it be assumed this would be targeted for 1.0? As you mentioned in #2981 it would speed up porting of controls which would then open up the floodgate of fixes and new controls coming over from WPF. |
Beta Was this translation helpful? Give feedback.
-
Would be nice if used with something like reacts contexts - resource dictionaries are not sufficient because they cannot override parent values iiuc. |
Beta Was this translation helpful? Give feedback.
-
Some High level requirements:
Any theme should be able to express: Default colours (probably Light) If a theme only expresses 1, (it has to be the default) and thats what avalonia falls back to say when HighContrast is asked for.
Im rendered with Default theme, instead of HighContrast... This is common for parts of apps that express branding, logos, media, etc or something way of expressing the same thing. In UWP they have RequestedTheme property and its an enum with Light / Dark... it seems like UWP is limited to just 2 themes at first... however that is not the case. because the OS has the concept of Light and Dark that enum expresses that. A MacOSX theme for UWP is possible, but the theme itself should optionaly define the Default, Dark and High contrast themes |
Beta Was this translation helpful? Give feedback.
-
This is an API breaking change as I understand it and in #2239 (comment) it's mentioned 0.11 is going to lock down breaking changes considerably. What happens to this if it doesn't make 0.11? Will it never get implemented? This is a fundamentally important feature as I see it to the styling system. The current CSS like system is quite powerful but this issue needs to get closed to finish it. (Triggers would be nice too but I suppose behaviors exist for that) Without this change themes and control styles are more complex than they need to be. We need to wrap each controls default style and template into a single parent container "Style". |
Beta Was this translation helpful? Give feedback.
-
@robloo this will get implemented, breaking changes will cause the major revision number to increase by 1. btw... 0.11 will never be released... the next major version will be 11.0.0 |
Beta Was this translation helpful? Give feedback.
-
Work was started on this a while ago on https://github.com/AvaloniaUI/Avalonia/commits/feature/2769-control-themes - just needs to be finished off. |
Beta Was this translation helpful? Give feedback.
-
In the design of Style, the design of XAML is very bad. It is highly redundant and difficult to read. I suggest adding support for CSS-3 directly. Use various advanced improvements made to CSS styles in the web(sass,less,scss...) . |
Beta Was this translation helpful? Give feedback.
-
GTK eventually went that route too. However, I think you should create a new issue for that. WPF styling with triggers was pretty intuitive and easy to read. UWP muddied things up a bit for beginners with the VisualStateManager (It also meant hardcoded string states in code-behind which I don't prefer). I'm not a huge fan of pseudoclasses here in Avalonia either but they are more powerful than just triggers on standard properties and work similar in my mind to UWPs VisualStates. Regardless, XAML styling is fairly straightforward once you get used to it and is far more powerful in Avalonia. The only issue is there is no container for them and you end up with lots of fragments for one control's default style. That is what I hope this issue fixes. |
Beta Was this translation helpful? Give feedback.
-
Someone has already raised it, and I have already expressed support in this issue. As for which one is better, <Style Selector="TabControl">
<Setter Property="Background" Value="#F0F0F0"/>
<Setter Property="Height" Value="120"/>
</Style> TabControl{
Background:#F0F0F0;
Height:120;
} |
Beta Was this translation helpful? Give feedback.
-
I won't argue which one is better. Each has preferences for certain reasons. I will say XAML isn't difficult. This issue is for something different than a full CSS/JSON styling system though. |
Beta Was this translation helpful? Give feedback.
-
Why it's not trivial to implement right now. I see following design as a solution: Define "default" theme for button: <ResourceDictionary>
<ControlTheme Type="Button" x:Key="FluentButtonStyle">
<Style Selector="Button">
<Setter Property="Template" Value=" ... " />
</Style>
<Style Selector="Button:pointerover">
<!-- -->
</Style>
</ControlTheme>
</ResourceDictionary> Apply default theme globally: <Styles>
<Style Selector="Button">
<Setter Property="ControlTheme" Value="{StaticResource FluentButtonStyle}" />
</Style>
</Styles> Develop will be able to completly ignore default theme and implement their own in the same way, OR they can base on it: <Styles>
<Style Selector="Button">
<Setter Property="ControlTheme">
<ControlTheme Type="Button" BasedOn="{StaticResource FluentButtonStyle}">
<Setter Property="Height" Value="66" />
</ControlTheme>
</Setter>
</Style>
<!-- Or create a new one which will not be based on any other theme -->
<Style Selector="Button.special-button">
<Setter Property="ControlTheme">
<ControlTheme Type="Button">
<Setter Property="Height" Value="22" />
</ControlTheme>
</Setter>
</Style>
<!-- And old global styles will work too -->
<Style Selector="Button">
<!-- Will be applied to every button -->
</Style>
</Styles> Questions/problems:
|
Beta Was this translation helpful? Give feedback.
-
I think something like this is more readable and less verbose: <Styles>
<Style Selector="Button" BasedOn="{StaticResource FluentButtonStyle}">
<Setter Property="Height" Value="66" />
</Style>
<!-- Or create a new one which will not be based on any other theme -->
<Style Selector="Button.special-button" BasedOn="{StaticResource FluentButtonStyle}">
<Setter Property="Height" Value="22" />
</Style>
<!-- And old style global styles will work too -->
<Style Selector="Button">
<!-- Will be applied to every button -->
</Style>
</Styles> |
Beta Was this translation helpful? Give feedback.
-
After thinking about this a while, I think adding a new
Honestly, we should probably have named themes similar to pseudo-classes and then have an additional theme selector evaluated for each style. The styles themselves can decide which theme they apply to. |
Beta Was this translation helpful? Give feedback.
-
Hi, I want to understand the limitation of |
Beta Was this translation helpful? Give feedback.
-
The current styling system isn't really suitable for defining controls themes:
So we need a switchable group of styles that can be associated with a control like
Style
is associated with one in WPF and basically act like WPF's style.Such control theme could be switched and manipulated by selectors in our regular CSS-like styles.
A control would announce its default theme by implementing
which would be generated by the XAML compiler based on
x:DefaultControlThemeFor
in a XAML file in the same assembly:Beta Was this translation helpful? Give feedback.
All reactions