When styling multiple sliders with class selectors, only the last selector works
See original GitHub issueDescribe the bug When there are multiple styles for sliders defined using class selectors, only the last selector is valid and works.
To Reproduce
- Add 2 sliders with different classes to a control.
- Create two styles for each slider.class (they can have the same Minimum and Maximum values).
- Only the slider with class that is defined last in the selectors will work.
OR use the following code:
<Window.Styles>
<Style Selector="Slider.percentSlider">
<Setter Property="Minimum" Value="0"/>
<Setter Property="Maximum" Value="100"/>
</Style>
<Style Selector="Slider.colorSlider">
<Setter Property="Minimum" Value="0"/>
<Setter Property="Maximum" Value="100"/>
</Style>
</Window.Styles>
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<StackPanel>
<Slider Classes="colorSlider"/>
<Slider Classes="percentSlider"/>
</StackPanel>
Expected behavior Both sliders should work correctly.
Screenshots The second slider cannot be moved
Desktop (please complete the following information):
- OS: Windows 10
- Version 10.14
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
last-of-type - CSS: Cascading Style Sheets - MDN Web Docs
The :last-of-type CSS pseudo-class represents the last element of its type among a group of sibling ... Multiple selectors elements.
Read more >select second active slide in slickslider through css-selector
I am using slick slider and showing 3 slides, I would like to add specific styling on the center slide. by using nth-of-type...
Read more >nth-last-child() - CSS: Cascading Style Sheets - MDN Web Docs
Represents every <p> element among a group of siblings. This is the same as a simple p selector. (Since n starts at zero,...
Read more >How to select "last child" with a specific class using CSS
Approach: The CSS :last-child selector is used to target the last child element of its parent for styling. Syntax: :last-child { // CSS...
Read more >Useful :nth-child Recipes
Select Only the Fifth Element · Select All But The First Five · Select Only The First Five · Select Every Fourth, Starting...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rabbitism correct, expected behavior would be to throw an exception. And it is done with that PR https://github.com/AvaloniaUI/Avalonia/pull/8600
Thanks for the detailed explanation and discussion. I agree that throwing an exception would be best since this is not supported. The use case was indeed to apply the same properties to a large number of controls, so I will try using data templates to achieve that.
One more weird thing that I do not understand - the styling of data properties seems to work correctly when I set the Maximum to a Binding. That is how it originally was in the code I have inherited. Do you know why that works if it is not supported?