Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 449379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:45:49+00:00 2026-05-12T21:45:49+00:00

I may have missed something obvious with WPF, but is it possible to create

  • 0

I may have missed something obvious with WPF, but is it possible to create styles that work hierarchically with the targeted control’s child controls? To better explain, think of how CSS works to style HTML. You can hierarchically target controls with CSS via selectors:

div > span em
{
   color: blue;
}

ul.class > li ul li
{
    display: block;
    margin: 0px;
}

Is it possible to achieve the same thing with WPF styles? So far, I have been creating styles for every type of control, or named styles that I directly apply to a control. However, I end up with a hell of a lot more styles than I really intend, and I is nearly impossible to style control structures together as a group.

Thanks for any insight.

UPDATE:

Here is an example of what I would like to be able to do. Note that only the root ListView control has a Style applied. I would like to be able to target any one of the child controls in any one of the CellTemplates without having to directly apply the style to each of those child controls. This keeps my view layout markup more decoupled and isolated from the style markup, giving me a lot more freedom to change the style without having to explicitly create a style for every single control in my entire application.

<Grid>
  <ListView Style="{StaticResource ProcessableItemsListView}">
    <ListView.View>
      <GridView>
        <GridViewColumn Width="10">
          <GridViewColumn.CellTemplate>
            <Grid>
              <CheckBox Value="{Binging ...}" />
            </Grid>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
        <GridViewColumn Width="*">
          <GridViewColumn.CellTemplate>
            <Grid>
              <TextBlock Text="{Binding ...}" />
            </Grid>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
        <GridViewColumn Width="80">
          <GridViewColumn.CellTemplate>
            <Grid>
              <Button Command="{Binding ...}">Process</Button>
            </Grid>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
        <GridViewColumn Width="120">
          <GridViewColumn.CellTemplate>
            <Grid>
              <ProgressBar Value="{Binding ...}" />
            </Grid>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
      </GridView>
    </ListView.View>
  </ListBiew>
</Grid>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:45:49+00:00Added an answer on May 12, 2026 at 9:45 pm

    I would have made this a comment but ran out of characters

    Hmmm. Given that the answer from andyp of using implicit styles doesn’t solve your problem I can think of two slightly different ways to do this.

    One is to make all the controls in your grid cells be simple content controls and bind a data object to the Content property of the control. Then you can create implicit styles that are targeted at your data object, instead of the the UI control type. This is pretty much the same thing andyp suggested but just looking at it from a data perspective (which may not work in your scenario)

    The other solution I could think of is to create a style targeted at some root UIElement that all of your grid cell controls inherit from. In the style add a trigger to swap certain properties of your control based on some value (Name, Tag, some other data binding).

    Not sure that either of those will get what you want but it’s worth a shot.

    Also, could you post a code snippet that shows more clearly what you are trying to accomplish. There may be a much simpler way to solve this problem that I am just missing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like I've missed something obvious, but when creating a custom control in
In PHP I can name my array indices so that I may have something
I've read through the logging module documentation and whilst I may have missed something
Edit: It turns out I missed something obvious, but I'm going to leave the
You may have noticed that we now show an edit summary on Community Wiki
I have a CSV data file with rows that may have lots of columns
I'm merging in a remote branch that may have a lot of conflicts. How
I need to be able to take an arbitrary text input that may have
You may have seen JavaScript sliders before: http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html What I'm envisioning is a circular
I have a table with columns Index, Date where an Index may have multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.