Take the 2-minute tour ×

I have a simple WPF application with a DataGrid, in my application resources I have created new styles for most of the DataGrid components and most of them are applied correctly. However I have not been able to override the style for the DataGridColumnFloatingHeader.

The DataGridColumnFloatingHeader is an internal control in System.Windows.Controls that is used to display the header being dragged when re-ordering columns in the DataGrid. The default style uses a ComponentResourceKey, DataGridColumnHeader.ColumnFloatingHeaderStyleKey, and is basically an image of the column header being dragged with some opacity and a light blue border (in the aero theme at least).

I assumed that I would just be able to add a style into the application resources that uses the ComponentResourceKey and changes the border colour to Red.

In the example window below I would expect that first 2 columns would have a red border when dragging and the last column would have the magenta border from the explicit style. The magenta border works but the red border does not.

<Window x:Class="DataGridStylingTest.MainWindow"
        <Style x:Key="{x:Static DataGridColumnHeader.ColumnFloatingHeaderStyleKey}" TargetType="{x:Type Control}">
        <Style x:Key="TestColumnFloatingHeaderStyle" TargetType="{x:Type Control}">
            <Setter Property="BorderBrush" Value="Magenta"/>
        <DataGrid AutoGenerateColumns="False">
                <DataGridTextColumn Header="First Name"/>
                <DataGridTextColumn Header="Last Name"/>
                <DataGridTextColumn Header="Date Of Birth" DragIndicatorStyle="{StaticResource TestColumnFloatingHeaderStyle}"/>

I don't want to have to add the DragIndicatorStyle property for all columns, also I can't use this easily if my DataGrid generates the columns automatically.

Does anyone know why this style is not applied and if there is something I can do to make this work as I expect?

share|improve this question
Couldn't you set the DragIndicatorStyle property on the DataGrid? Doing that would change the style for all columns.. –  Peter Hansen Jan 4 '13 at 19:53
Hi Peter, thanks, I didn't notice that property was on the DataGrid as well. So yes, that works, and I can add that property to a default DataGrid style so that all my DataGrids have that property implicitly. However I would still like to know why just using the component resource key doesn't work. –  FallLine Jan 4 '13 at 20:11
add comment


Your Answer



Browse other questions tagged or ask your own question.