I found an example in the documentation on how to change the column headers style. It suggests creating a style with LabelPresenter as the target type and ommitting a key so that it is applied to all column headers. I need to change the style on just a few headers. Is there a way I can assign a header style per column?
Thanks for your help,
Mike
You da man! That did the trick. Thanks!
Sorry the snippet I provided had a mistake. You just need to remove the StaticResource since that property will return the style.
<Style TargetType="{x:Type igDP:LabelPresenter}"
BasedOn="{x:Static igThemes:DataPresenterOnyx.LabelPresenter}">
That makes sense, thanks Andrew. I'm having trouble getting this to work however. In your sample you set the BasedOn as DataPresenterOnyx.LabelPresenter. Is LabelPresenter the name of the Style and the Type? My understanding is BasedOn has to refer to a Style. I think this might be why it is not working for me. What is the name of the LabelPresenter Style in the Onyx theme?
Thanks again,
Mike.
Since the Style resolution in WPF is such that once it finds a Style, it will only fallback to the style in the defining assembly (the default style), I think you will need to set the BasedOn of the Style to that style in the onyx theme.
e.g.
<Style TargetType="{x:Type igDP:LabelPresenter}" BasedOn="{StaticResource {x:Static igThemes:DataPresenterOnyx.LabelPresenter}}">
Note, if you change the theme property or put a different theme resourcedictionary into the resources then you will need to change the based on accordingly.
Thanks for your help Andrew, that clears it up.
One more problem I'm having, if you wouldn't mind helping. I'm using the "Onyx" theme which creates very attractive headers with small rectangles around the header label (as well as a slight blue glow affect on mouse-over). When I set a field to use my LabelPresenterStyle, and the only thing in the style is to change the foreground, I lose the rectangle around the label, I lose the mouse-over effect, the bottom of the header changes (there's a control-color line across the bottom), and the vertical alignment of the header text shifts. Is there a way I can override the LabelPresenterStyle but still preserve most of the nice visuals provided by the theme?