AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.37k stars 2.2k forks source link

TabItem State Styling requires internal knowledge of control's coding (Bad Design Karma!!!) #14130

Closed KentSwan closed 8 months ago

KentSwan commented 8 months ago

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

To style the content of a tabitem I have the following style settings.

    <Style Selector="TabControl">
        <Setter Property="Padding" Value="0 0 0 0"/>
        <Setter Property="Margin" Value="0 0 0 0"/>
    </Style>
    <Style Selector="TabItem">
        <Setter Property="BorderBrush" Value="Blue"/>
        <Setter Property="BorderThickness" Value="2"/>
        <Setter Property="CornerRadius" Value="8 8 0 0"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="Foreground" Value="Black"/>
    </Style>
    <Style Selector="TabItem:selected /template/ ContentPresenter#PART_ContentPresenter">
        <Setter Property="Background" Value="Black"/>
        <Setter Property="Foreground" Value="Yellow"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="FontStyle" Value="Italic"/>
    </Style>

The first TabItem style sets the unselected tab style elements The second Tabitem style set the selected tab style elements.

My issue is that the :selected attribute tag should be suffient to do this without having to know and specify control internal information.

Describe the solution you'd like

A clear and concise description of what you want to happen.

When you add state attributes to a control component for styling, the backing concept is that the properties set override the base properties of that control component based on the state attribute being true or ignored if false.

I would thus like to have