How can I override the default pointerover style for a button? #17822
-
I can't find the pointerover pseudo-class for the button selector, and I have a situation where I need to change the font color when a ListBoxItem is selected. I wrote the style like this <Style Selector="ListBox:not(.Base) ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="{StaticResource MainColor}"/>
<Setter Property="Foreground" Value="{StaticResource FontColor}"/>
<Style Selector="^ Button">
<Setter Property="Foreground" Value="{StaticResource FontColor}"/>
</Style>
</Style> but it's useless |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You always need to read the relevant If you look through it, you'll see properties are applied to the internal <Style Selector="ListBox:not(.Base) ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{StaticResource MainColor}"/>
<Setter Property="Foreground" Value="{StaticResource FontColor}"/>
<Style Selector="^ Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{StaticResource FontColor}"/>
</Style>
</Style> There may be some simplifications, but it's not entirely clear how much customization you want. |
Beta Was this translation helpful? Give feedback.
I'm using Fluent theme for this example.
There's some issue with going through templated
ContentPresenter
s twice or some rule I don't understand. I've tried the following and it doesn't work:What does work is separating them without nesting: