Hello,
I'm trying to change the background color of a Column Header (blue background) and the Filter Clear button (white background).
In the case of the Column Header, I have tried to re-style the LabelPresenter with limited success. I am able to change the Foreground color, the LabelHighlight, but when I set the Background color nothing happens. Using Snoop I can see that the Background color is set inside of an element called CardPanel (hightlist_2, not sure where this is defined).
In the case of the Filter Button, I have tried to change the background in the DataRecordPresenter and also the RecordSelector. According to Snoop, the color is stored in the Mainborder. Once again, accessing th background property for this is not obvious.
I really don't want to create a new template for either of these as all I want to do is change the background I'm surprised there isn't a functioning property to set the background for either of these as I would think changing the background would be a commonly used feature.
Any help would be greatly appreciated.
The background property of the RecordSelector (where these elements appear) is bound to the Fill property of the paths (RecordSelector,FilterButton). This is so, because it is a path element and its background is its fill rather than the background of the area around it.
You are correct - the element MainBorder (Grid) holds the background of the area around the RecordSelectors. You can see the default xaml files that we ship in the DefaultStyles directory and get from there the default style for the RecordSelector. From there you can easily change the color that you want.
You can do the same for the Labelpresenter, however, I do not understand why simply changing the background does not work with you.
<Style TargetType="{x:Type igDP:LabelPresenter}">
<Setter Property="Background" Value="Green"/>
</Style>
Please provide the xaml you are using for the LabelPresenter in your next post so that we can look into it.
1. So I do need to make a clearification about my original post. I am able to change the background of the column header. The problem I'm having is changing the background of the sort button (blue element labeled "Device Name" in attached image.). I think it's just a button?
Here is my LabelPresenter style:
<Style TargetType="{x:Type xamDataGrid:LabelPresenter}"> <Setter Property="Foreground" Value="White"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="LabelHighlight" Value="Gray"/> <Setter Property="InnerBorderBrush" Value="#FF474747"/> <Setter Property="OuterBorderBrush" Value="#FF535353"/> <Setter Property="BorderBrush" Value="#FF535353"/> </Style>
2. I'm also having a hard time finding the the background for the filter clear button (the White Button on the left of the the attached image).
3. Finally, how do I change the background of the Filter options, currently it's white (see second image)?
I am attaching a sample project with custom sorting indicator and custom clear record filter button.
Hope this helps.
Hi Alex,
Thanks for the sample xaml. So how do I change the Blue gradient background of the control that contains the SortIndicator?
Also, how do I hide the column in which the FilterRecordClearButton resides?
Thanks
Also, the background color of the filter selector scroll box.
The dropdown of the Filter DropDown cannot be customized for now. The only way that I know of is with a style for the ComboBoxItem. The FilterRecordClearButton is actually the RecordSelector for that records, so in order to remove that, you need to hide the RecordSelector.
You can set that with the RecordSelectorLocation property of the FieldLayoutSettings object of the XamDataGrid.
Great! Almost there.
The last two things I need to change are the Blue gradient background of the UI element that contains the SortIndicator and the white border. See the previous screen captures. In Snoop I am able to see two LabelPresenters (both of my headers) in the VirtualizingDataRecordCellPanel. I need to modify the background of the highlight_2 and the BorderBrush of the WhiteInnerBorder inside of each LabelPresenters.
Many Thanks
Using the default style, you can set the LabelHightligh property to transparent, remove the border responsible for highlighting. You should also remove the triggers and storyboards, which targetname is this border.