question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nth-child selector

See original GitHub issue

Is your feature request related to a problem? Please describe.

We had some talk about this internally, but I am repeating it here for visibility: It would be nice to have some CSS-like nth-child selector that allows you to style every nth descendant.

Describe the solution you’d like

<Style Selector="ListBox ListBoxItem:nth-child(2n+2)" />

(Would select every 2nd ListBoxItem)

The syntax is debatable, but it’s how CSS does it: https://css-tricks.com/how-nth-child-works/

Describe alternatives you’ve considered

WPF’s ItemsControl.AlternationIndex is not flexible enough IMO.

Additional context

CC: @grokys

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
maxkatz6commented, Jul 15, 2021

Good you mentioned it here. I did created simplifed classes setter that can be enabled with attached properties. Will be useful for anybody, who needs it, but can’t wait until Avalonia will get proper support for it. https://gist.github.com/maxkatz6/124dc79665462982c674b19d788ab6de

Read more comments on GitHub >

github_iconTop Results From Across the Web

nth-child() - CSS: Cascading Style Sheets - MDN Web Docs
:nth-child() takes a single argument that describes a pattern for matching element indices in a list of siblings. Element indices are 1-based.
Read more >
CSS :nth-child() Selector
The :nth-child(n) selector matches every element that is the nth child of its parent. n can be a number, a keyword (odd or...
Read more >
nth-child
The :nth-child selector allows you to select one or more elements based on their source order, according to a formula.
Read more >
Matching elements in CSS with :nth-child and other selectors
The :nth-child selector in CSS allows us to select and style a specific element based on its position in the parent container. Suppose...
Read more >
:nth-child() Selector | jQuery API Documentation
Description: Selects all elements that are the nth-child of their parent. version added: 1.1.4jQuery( ":nth-child(index/even/odd/equation)" ).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found