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

  • SEARCH
  • Home
  • 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 8689527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:40:09+00:00 2026-06-12T23:40:09+00:00

I am encountering a very weird issue. I am trying to apply global styling

  • 0

I am encountering a very weird issue. I am trying to apply global styling to several controls within a DataGrid. Most of them work exactly how I would expect them to. However, the styling for the TextBlock never gets applied. Styles for ComboBox, TextBox, Label, and several others all are getting applied to their respective controls, but not the TextBlock. I have simplified the code as much as possible and the issue is still present. I have provided the code sample below.

I need the style to be applied to the TextBlock and I don’t want to have to apply it manually to the TextBlock.

<DataGrid ItemsSource="{Binding Data}" AutoGenerateColumns="False">
    <DataGrid.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="ANY_TEXTBLOCK_PROPERTY" Value="VALUE" />
        </Style>
    </DataGrid.Resources>
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="Test">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="Globably Applied" />
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

More Information:

  • Global styles for any control other than TextBlock (TextBox, ComboBox, etc.) work properly.
  • Defining the global style inside the DataTemplate will work properly.
  • Directly assigning the style to the TextBlock using an x:Key will work.
  • Global styles for DataGridCell using TextElement.PROPERTY will get applied to a TextBlock.

While some of these will get the style applied to the TextBlock, they have there own issues. Directly assigning the style or defining the style somewhere within a DataGridColumn will mean that I will have to apply the style more than once. Using the TextElement.PROPERTY on the DataGridCell will apply the style to more than just TextBlock controls and will limit the number of properties that you can set.

  • 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-06-12T23:40:10+00:00Added an answer on June 12, 2026 at 11:40 pm

    So with a bit more digging and a little luck, I discovered that WPF does not apply implicit styles inside templates unless the TargetType derives from Control. Since TextBlock doesn’t derive from Control, its style is not applied. So you either have to manually apply the style to every non-Control or define the implicit style inside the template.

    The following MSDN blog post explains it in pretty good detail.

    https://learn.microsoft.com/en-us/archive/blogs/wpfsdk/implicit-styles-templates-controls-and-frameworkelements

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

Sidebar

Related Questions

So I'm just getting started with F#, and I'm encountering a very weird issue
I am using Faye in a rails application and I'm encountering a very weird
I am encountering the following problems trying to work through the quagmire of settings
I'm writing a very basic Facebook app, but I'm encountering an issue with cross-domain
I'm encountering a very strange issue while debugging a unit test. If I debug
I'm encountering a very strange problem: my delete actions in rails don't work anymore.
I am encountering a very strange issue I wonder if anyone has seen before.
I seem to be encountering a very odd problem which only occurs when trying
I am encountering a very strange error with my project. I normally use the
I'm encountering a strange issue, where sqlsrv_query() returns a valid statement resource, but sqlsrv_fetch_array()

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.