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.

Nested Style Selectors

See original GitHub issue

It would be nice if we could do something like this:

<Style Selector=".SomeClass">
  <Style Selector="TextBlock#SomeText">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <Style Selector="StackPanel#SomeStackPanel">
    <Setter Property="Background" Value="Red" />
  </Style>
</Style>

This would allow better organized styles by logically grouping related selectors. This is similar to how LESS and SASS allow nested selectors to improve on plain CSS.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
robloocommented, Dec 7, 2022

This is complete now, correct?

1reaction
sards3commented, Feb 20, 2020

Probably .SomeClass TextBlock#SomeText. Then another possibility would be:

<Style Selector=".SomeClass">
  <!-- Next line is equivalent to: .SomeClass TextBlock#SomeText  -->
  <Style Selector="TextBlock#SomeText">
    <Setter Property="IsVisible" Value="False" />
  </Style>
  <!-- Next line is equivalent to: .SomeClass > StackPanel#SomeStackPanel. Note the > at the start. -->
  <Style Selector="> StackPanel#SomeStackPanel">
    <Setter Property="Background" Value="Red" />
  </Style>
  <!-- If we want to get fancy, we could also follow LESS/SASS by using & as the parent selector, like so: -->
  <!-- Next line is equivalent to: .SomeClass.AnotherClass -->
  <Style Selector="&.AnotherClass">
    <Setter Property="Background" Value="Blue" />
  </Style>
</Style>
Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Nesting - Chrome Developers
CSS nesting allows you to define styles for an element within the context of another selector. ... In this example, the .child class...
Read more >
Grouping and Nesting CSS Selectors
It's that simple. To nest a selector, you simply separate them with a space. But what if you had a third paragraph tag...
Read more >
Native CSS nesting: What you need to know
As you can see from both code samples above, nesting is enclosing a selector inside another selector. Nesting helps you to group related...
Read more >
How to Nest Your CSS Selectors for Cleaner Code
Nesting your CSS selectors is one small trick that makes things much easier down the road. You'll write your CSS more quickly, apply...
Read more >
CSS Nesting | Can I use... Support tables for HTML5, CSS3 ...
CSS nesting provides the ability to nest one style rule inside another, with the selector of the child rule relative to the selector...
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