I've added a summary record to one of my grids, binding the background to the convenient HeaderAreaBackground property, and although the text is only white, I'd like a way to bind the foreground as well. Is there a better way without replicating the themed header styling (Onyx) I'm using?
<Style TargetType="igDP:SummaryRecordPresenter">
<Setter Property="Background" Value="{Binding HeaderAreaBackground, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Foreground" Value="#fff"/>
</Style>
Hello Darryl,
I have been looking into your post. If you are trying to set the Foreground property of the SummaryRecordPresenter when you are using the Onyx theme for the XamDataGrid, you could set the BasedOn property for the SummaryRecordPresenter style:
<igDP:XamDataGrid.Resources>
<Style TargetType="igDP:SummaryRecordPresenter" BasedOn="{x:Static igThemes:DataPresenterOnyx.SummaryRecordPresenter}">
<Setter Property="Background"
Value="{Binding HeaderAreaBackground, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Foreground"
Value="#fff"/>
</igDP:XamDataGrid.Resources>
This will allow you easily to apply a style for the component when you are using a theme.
Please feel free to let me know if I have misunderstood something in your scenario or if you have any questions on the matter.
Hi Maria,
I wasn't very descriptive in my initial post, was I? I'd like to find a way to bind the summary record to the header fore/background, such that if the grid style changes, I won't have to change the summary record styling. The HeaderAreaBackground property just happened to be there already (for what reason I'm not sure, but I suspect the base class had it for other types), and I'd like to find a way to bind the foreground as well. Unless there is a better approach altogether. Hope this is clearer. Thanks.
Thank you for the provided details. You could change the foreground color according to the header foreground by dynamically binding its value to the LabelForeground:
Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type igDP:XamDataGrid}, ResourceId=LabelForeground}}"/>
Similar binding is used for the HeaderAreaBackground in the default style which change the summary row background according to the header background. I have attached a sample project where I have used this approach. If you click the button below the DataGrid, the theme of the summary row will be changed and the foreground color of the summary will also get new value.
Please do not hesitate to ask if you have any questions.