question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The current styling system isn’t really suitable for defining controls themes:

  • we don’t have a way to properly specify the default theme
  • we don’t have a way to completely re-style a control and prevent the current theme selectors from leaking to such re-styled control

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.

<Button>
    <Button.ControlTheme>
        <ControlTheme BasedOn="{x:StaticResource SomeBaseButtonTheme}">
             <Setter Property="Background" "Value"="Red"/>
             <Style Selector=":pointerover">
               <Setter Property="Background" "Value"="Green"/>
             </Style>
        </ControlTheme>
    </Button.ControlTheme>

</Button>

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

interface IHaveDefaultControlTheme
{
       Style GetDefaultControlTheme();
}

which would be generated by the XAML compiler based on x:DefaultControlThemeFor in a XAML file in the same assembly:

<ControlTheme x:DefaultControlThemeFor="{x:Type MyControl}">

</ControlTheme>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
sgfcommented, Dec 10, 2021

I suggest adding support for CSS-3 directly. Use various advanced improvements made to CSS styles in the web(sass,less,scss…) .

GTK eventually went that route too. However, I think you should create a new issue for that.

Someone has already raised it, and I have already expressed support in this issue. https://github.com/AvaloniaUI/Avalonia/issues/3686

As for which one is better, the shorter the better, the smaller the number of typing characters, the better, and the smaller space in view of the same function, the better.

<Style Selector="TabControl">
    <Setter Property="Background" Value="#F0F0F0"/>
    <Setter Property="Height" Value="120"/>
</Style>
TabControl{
Background:#F0F0F0;
Height:120;
}
1reaction
grokyscommented, Nov 1, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Theme of the Day: Control
Theme of the Day: Control · Control of Self · Control of Others · Control of Circumstance · Control of Nature · Control...
Read more >
CONTROL - Theme and Symbolism
Control is an illusion. We all need to be in control of something. The only thing you can control is your attitude and...
Read more >
22: Power and Control - Chaos, Revenge, and Nurturing ...
This episode is part two of the theme “Power and Control.” It covers how this theme can manifest in clients as chaos, revenge, ......
Read more >
Story Theme: Definition and Examples for a Controlling Idea
Examples of Controlling Ideas (or Themes) in Story · The Bluest Eye by Toni Morrison (Society) · A Farewell to Arms by Ernest...
Read more >
Defining themes for controls
Defining themes for controls. For theming controls, define the new theme entries in the Plug-in_id _ theme_name .ythm file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found