benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.73k stars 145 forks source link

Extend style of control styled with Classic Theme? (.NET 7) #200

Closed ividyon closed 1 year ago

ividyon commented 1 year ago

Sorry if this is already explained somewhere.

Using .NET 7.

I'm trying to change some aspects of a styled TabItem in my App.xaml:

<Application x:Class="RainbowStoneWPF.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:RainbowStoneWPF"
             xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
             xmlns:system="clr-namespace:System;assembly=System.Runtime"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI;component/ColorSchemes/Dark.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI.ClassicTheme;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <system:Double x:Key="{x:Static adonisUi:Dimensions.HorizontalSpace}">10</system:Double>
            <system:Double x:Key="{x:Static adonisUi:Dimensions.VerticalSpace}">10</system:Double>
            <Style x:Key="{x:Type TabItem}" TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
                <Setter Property="Margin" Value="{adonisUi:Space 1, 2}"></Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

But whenever I try to change the style of an item, only this one style applies. None of AdonisUI's other changes do. It essentially resets to a standard TabItem.

image

As you can see, the tab headers are now white, and the content has black text. The other tab items also vanished.

Without the <Style> it all works correctly:

image

The documentation mentions "BasedOn", and I do use it, but seemingly to no effect. I do notice there is no reference to AdonisUI.ClassicTheme which would contain these changes, but I can't get the reference to happen.

What to do?

ividyon commented 1 year ago

This was the solution:

https://github.com/benruehl/adonis-ui/issues/157#issuecomment-913143958