benruehl / adonis-ui

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

How to set adonisExtensions:xyz in Style #175

Open modmanx opened 2 years ago

modmanx commented 2 years ago

Hello, we would like to use for example adonisExtensions:CursorSpotlightExtension.BackgroundBrush in Style, but while program compiles, Button doesnt get CursorSpotlightExtension. If we move this directly to Button, it works as it should. Is there any specific thing we forgot to do?


    <Window.Resources>
        <Style x:Key="ControlsButtonStyle"
           TargetType="Button"
           BasedOn="{StaticResource {x:Type Button}}">
            <!-- does not apply-->
            <Setter Property="adonisExtensions:CursorSpotlightExtension.BackgroundBrush" Value="Red"/>
            <Setter Property="adonisExtensions:CursorSpotlightExtension.BorderBrush" Value="Red"/>

            <!-- this one works fine -->
            <Setter Property="Foreground" Value="{DynamicResource {x:Static adonisUi:Brushes.AccentForegroundBrush}}"/>
            <Setter Property="Background" Value="{DynamicResource {x:Static adonisUi:Brushes.AccentHighlightBrush}}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static adonisUi:Brushes.AccentHighlightBrush}}"/>
        </Style>
        </Window.Resources>
irusanov commented 2 years ago

@modmanx You can see the defined properties in the source, which will give you and idea what to override. The styles for default buttons can be found here: https://github.com/benruehl/adonis-ui/blob/master/src/AdonisUI.ClassicTheme/DefaultStyles/Button.xaml

I think you need to override the Style Triggers for each state if you're interested in the CursorSpotlightExtension Otherwise, if you want to override them "globally" for the Button, use these instead:


<Setter Property="adonisExtensions:RippleExtension.BackgroundBrush" Value="Red"/>
<Setter Property="adonisExtensions:RippleExtension.BorderBrush" Value="Red"/>