views:

1371

answers:

3
+3  A: 

try putting

<Style
  x:Key="DataGrid_Style"
  TargetType="wt:DataGrid"
  BasedOn="{StaticResource {x:Type wt:DataGrid}}">

to base your style on the current datagrid one, and the same for the headers

<Style
  x:Key="DataGrid_ColumnHeaderStyle"
  TargetType="wt:DataGridColumnHeader"
  BasedOn="{StaticResource {x:Type wt:DataGridColumnHeader}}">

scratch the above - i pulled your style down to the offending element

   <Style
     TargetType="wt:DataGridColumnHeader"
     BasedOn="{StaticResource {x:Type wt:DataGridColumnHeader}}">
     <Setter
        Property="Background"
        Value="Blue" />
  </Style>

if you set the background (or the border brush ) you're screwed.

I found this link on code project, to back this up -

"The style of the column header can easily be modified via the ColumnHeaderStyle of the DataGrid. However, if you modify the background colour of the column header, you will find that the sort arrows disappear! This is because the arrows are not part of the ColumnHeader template; instead, they are added programmatically."

he has a style that re-adds the sort indicators.

i have had a look at the code for DataGridHeaderBorder (which is the border of the datagridrowheader) which does not have its own control template, it simply derives from border. As well as the seperators being added programatically (the separators are just rectangles see line 1199 of DataGridHeaderBorder.cs) the sort indicators are. the brief look at the code that i had would suggest they should still get drawn but they dont, a step thru of the code is in order.

The solution is to override the control template i think, and add them yourself, the link on code project will get you started.

Aran Mulholland
@Aran, thanks for the answer, but adding the `BasedOn` attributes made no difference.
DanM
@Aran, thanks. I will give that a try. I was just trying out a similar solution I found on codeplex, and it seems to work also, except that the arrow end up overlapping the text. Maybe the codeproject example you linked will work better. I assume I need to fill in the default template markup for `<dg:DataGridHeaderBorder .../>` and `<Thumb ... />`.
DanM
yeah probably just copy the one straight out of the toolkit. the answer to your question "Is this a bug?" is probably yes (i never like to fully commit myself :). im glad you found this, i just hope i remember when i come up against it.
Aran Mulholland
According to the thread I found on Codeplex (http://www.codeplex.com/wpf/Thread/View.aspx?ThreadId=37625), it's definitely a bug (and one that will likely be fixed when the toolkit is actually implemented into the framework). Meanwhile, I've been working with the example you found. I've had to massage it somewhat to get the arrows to show up next to the header text and to get the separators back in there, but I think I've almost got a working solution (I'll post an answer with the code when I have it all working). Thanks for all your help.
DanM
+1  A: 
DanM
A: 

DanM,

Excellent description with image.. Saved my hair...

XYZ