adonis-ui icon indicating copy to clipboard operation
adonis-ui copied to clipboard

How to set adonisExtensions:xyz in Style

Open modmanx opened this issue 4 years ago • 1 comments

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>

modmanx avatar Nov 19 '21 10:11 modmanx

@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"/>

irusanov avatar Jan 12 '22 00:01 irusanov