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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:50:53+00:00 2026-05-18T09:50:53+00:00

I just converted a WPF project from .NET 3.5 to .NET 4.0. I’m now

  • 0

I just converted a WPF project from .NET 3.5 to .NET 4.0.

I’m now using the .NET 4.0 DataGrid control rather than the WPF Toolkit DataGrid control. Functionally, everything is still working, but my styles are not applying as expected.

As you can see from the below screen captures, the alternating row formatting, padding, bold headings, etc. have stopped working.


Before (WPF Toolkit DataGrid)

Screen capture of WPF Toolkit DataGrid

After (.NET 4.0 DataGrid)

Screen capture of .NET 4.0 DataGrid


Here is my entire resource dictionary.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="DataGrid_ColumnHeaderStyle" TargetType="DataGridColumnHeader">
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="TextBlock.TextAlignment" Value="Center" />
        <Setter Property="TextBlock.TextWrapping" Value="WrapWithOverflow" />
    </Style>
    <Style x:Key="DataGrid_CellStyle" TargetType="DataGridCell">
        <Setter Property="Padding" Value="5,5,5,5" />
        <Setter Property="TextBlock.TextAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="DataGridCell">
                    <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="DataGrid">
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGrid_ColumnHeaderStyle}" />
        <Setter Property="CellStyle" Value="{StaticResource DataGrid_CellStyle}" />
        <Setter Property="Background" Value="White" />
        <Setter Property="AlternatingRowBackground" Value="#F0F0F0" />
        <Setter Property="VerticalGridLinesBrush" Value="LightGray" />
        <Setter Property="HeadersVisibility" Value="Column" />
        <Setter Property="SelectionMode" Value="Single" />
        <Setter Property="SelectionUnit" Value="FullRow" />
        <Setter Property="GridLinesVisibility" Value="Vertical" />
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="CanUserAddRows" Value="False" />
        <Setter Property="CanUserDeleteRows" Value="False" />
        <Setter Property="CanUserReorderColumns" Value="True" />
        <Setter Property="CanUserResizeColumns" Value="True" />
        <Setter Property="CanUserResizeRows" Value="False" />
        <Setter Property="CanUserSortColumns" Value="True" />
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="BorderBrush" Value="#DDDDDD" />
        <Setter Property="HorizontalGridLinesBrush" Value="#DDDDDD" />
        <Setter Property="VerticalGridLinesBrush" Value="#DDDDDD" />
    </Style>
    <Style x:Key="DataGrid_FixedStyle" TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
        <Setter Property="CanUserReorderColumns" Value="False" />
        <Setter Property="CanUserResizeColumns" Value="False" />
        <Setter Property="CanUserResizeRows" Value="False" />
        <Setter Property="CanUserSortColumns" Value="False" />
    </Style>
</ResourceDictionary>

Here is a usage example (note that the style is set to “DataGrid_FixedStyle”):

<DataGrid
    Style="{StaticResource DataGrid_FixedStyle}"
    Grid.Column="0" Foreground="Black"
    SelectedIndex="{Binding SelectedParticipantIndex, Mode=TwoWay}"
    ItemsSource="{Binding Participants}">
    <DataGrid.Columns>
        <DataGridTextColumn Foreground="Black" Header="Participant" Binding="{Binding ParticipantId}" />
        ....
    </DataGrid.Columns>
</DataGrid>

Note

To make sure the resource dictionary was really being used, I added the following setter to the <Style TargetType="DataGrid">...</Style>:

<Setter Property="FontSize" Value="24" />

As you can see from the screen capture below, the font size is cartoonishly large, so the style itself is definitely not being ignored. The problem is that many of the settings are not being used or not working for some reason.

alt text


Any theory on what might have caused my styles to break?

  • 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-18T09:50:53+00:00Added an answer on May 18, 2026 at 9:50 am

    I think I found the culprit. In my App.xaml, I apply the “Aero” theme using the following declaration:

    <ResourceDictionary
        Source="/PresentationFramework.Aero,
        Version=3.0.0.0,
        Culture=neutral,
        PublicKeyToken=31bf3856ad364e35,
        ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
    

    After that, I include the resource dictionary that performs additional styling on the DataGrid using the following declaration:

    <ResourceDictionary
        Source="/CommonLibraryWpf;component/ResourceDictionaries/DataGridResourceDictionary.xaml" />
    

    If I remove the Aero theme, the custom styling applies correctly (although it loses its Aero look since I’m running this on Windows XP). This problem definitely didn’t occur in WPF 3.5, though. I’m not sure what exactly has changed between .NET 3.5 and 4.0 that would make this fail.

    Now I just have to figure out how to get the Aero theme and the custom DataGrid styling to work at the same time 🙂

    Edit

    Please see this followup question.

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

Sidebar

Related Questions

I have just converted a project from Visual Studio 2003 to 2005 and although
We've converted our solution from .NET 2.0 to .NET 3.5. All projects converted just
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
I am learning Python for a class now, and we just covered tuples as
I just started using GNU Emacs as my text editor and I am concerned
I'm just concerned about Windows, so there's no need to go into esoterica about
Just a curiosity: is there an already-coded way to convert a printed traceback back
I've just heard the term covered index in some database discussion - what does
How do I convert a datetime field in Grails to just date, with out
I am not concerned about other kinds of attacks. Just want to know whether

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.