views:

55

answers:

2

What should I put for BasedOn in this style?

<Style
    x:Key="DataGrid_ColumnHeaderStyle"
    TargetType="wt:DataGridColumnHeader"
    BasedOn="??????????"> <!-- I want this to be a reference to the default style -->
    <Setter
        Property="BorderBrush"
        Value="{StaticResource Media_RaisedBorderBrush}" />
    <Setter
        Property="Background"
        Value="{StaticResource Media_RaisedBackgroundBrush}" />
    <Setter
        Property="Foreground"
        Value="{StaticResource Media_RaisedForegroundBrush}" />
</Style>

I don't want to override the whole default style, I just want to change a handful of properties with setters.

EDIT:

I know how to use BasedOn, I just don't know the name of the style I'm trying to base my style on or where to find it. What is the name of the default/built-in style?

Edit 2:

Okay, I guess this isn't what I needed after all. It doesn't seem to make any difference whether I include BasedOn="{StaticResource {x:Type wt:DataGridColumnHeader}}" or not. The problem is that just setting the BorderBrush, Background, and Foreground is causing the sort arrows to disappear. I don't understand why this is happening because the sort arrows are defined in the ControlTemplate and I'm not editing/overriding the ControlTemplate. Where are my sort arrows? (I definitely have sorting enabled, and clicking the column header does cause the data to sort...it just doesn't show the arrows.)

+2  A: 

BasedOn="{StaticResource {x:Type TextBox}}"> and it will inherit from the default style(this is for TextBox but it works for every control).

Thanks...well that works, but it doesn't solve my problem. I will edit my post to explain.
DanM
+1  A: 

The way I understand it you don't need to specify the BasedOn to the default style. Maybe if you set OverridesDefaultStyle you would have to. I believe the default style will still hold true and only the properties you specify in your style setters will change.

As far as finding out more information about a default style / template, one way to do that is to open up your project in Blend and right click on the element you want to see the default template for and select "Edit Template...", then select Edit a Copy.

Jacob
@Jacob, thanks. I had thought that was how it worked, but when I attempted to use the style (`ColumnHeaderStyle="{StaticResource DataGrid_ColumnHeaderStyle}"`), the sort arrows stopped appearing on my DataGrid. I extracted the default style using Blend, and the arrow paths are part of the `ControlTemplate`, but I didn't override that--I only set `BorderBrush`, `Background`, and `Foreground`. So, I'm not clear what is getting overridden and what isn't.
DanM