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 7859975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:06:21+00:00 2026-06-02T22:06:21+00:00

I was browsing stackoverflow to try to figure out a way to style the

  • 0

I was browsing stackoverflow to try to figure out a way to style the GridViewColumns in my ListView. I came across this:

WPF Text Formatting in GridViewColumn

The top answer shows how to style one (1) GridViewColumn. My question is, is there a way to style these GridViewColumns in the Window.Resources so I don’t have to do it for each individual GridViewColumn?

  • 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-02T22:06:23+00:00Added an answer on June 2, 2026 at 10:06 pm

    There are a few possibilities:

    <!-- if style doesn't change -->
    <GridViewColumn CellTemplate="{StaticResource yourCellTemplate}"/>
    
    <!-- if you need to change it up based on criteria - template selector-->
    <GridViewColumn CellTemplateSelector="{StaticResource YourTemplateSelector}"/>
    
    <!-- same goes for headers -->
    <GridViewColumn HeaderTemplate="{StaticResource yourheaderTempalte}"/>
     ..or HeaderContainerStyle, HeaderTemplateSelector
    

    if you want to use template selectors: create a class, instanciate it in resource dict, and plug it in you gridview column, here’s a little sample

    public class MyTemplateSelector : DataTemplateSelector
    {
        public DataTemplate SimpleTemplate { get; set; }
        public DataTemplate ComplexTemplate { get; set; }
    
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
                     //if I have just text
                       return SimpleTemplate;
                     //if I have comments and other fancy stuff 
                         return ComplexTemplate;
    

    then in your ResourceDictionary

    <DataTemplate x:Key="ComplexTemplate">
        <Views:MyCustomControl DataContext="{Binding}"/>
    </DataTemplate>
    
    <Views:MyTemplateSelector
        x:Key="TxtVsExpensiveCell_TemplateSelector"
        SimpleTemplate ="{StaticResource SimpleTemplate}"
        ComplexTemplate="{StaticResource ComplexTemplate}"/>
    
       <!-- then you use it in your view like this -->
       <GridViewColumn CellTemplateSelector="{StaticResource TxtVsExpensiveCell_TemplateSelector}"/>
    

    If you don’t want to go through all that trouble, and just what to tweak styles of predefined controls, why not use DataGrid? It has predefined columns, where you can tweak styles per each..

    <DataGrid>
        <DataGrid.Columns>
            <DataGridTextColumn/>
            <DataGridCheckBoxColumn/>
            <DataGridHyperlinkColumn/>
            <DataGridCheckBoxColumn/>
                         ....there are several more column types!
        </DataGrid.Columns>
    </DataGrid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While browsing I came across this blog post about using the Wikipedia API from
I was just browsing Sizzle's source code and I came across this line of
While browsing MSDN documentation, you may come across this gem: TextBox.Watermark. Awesome! I've been
I was browsing StackOverflow when I encountered this question. Here the author mentions his/her
I have dug high and low around Google and StackOverflow to try and figure
Browsing through the source of a spring framework project i came across a method
Browsing the code sample from C# 4.0 in a nutshell I came across some
While browsing the code of an erlang application, I came across an interesting design
Browsing the nuget library, i came across Ninject.Extensions.Logging.nlog2 . Some googling and trying to
Browsing the boilerplate code at http://html5boilerplate.com/ I'm puzzled at this usage: <link rel=stylesheet href=css/style.css?v=1>

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.