I am styling the LabelPresenter for the WPF XamDataGrid (v 2013.2). I am using the default theme, and have created this style:
<Style TargetType="igdp:LabelPresenter"> <Setter Property="Background" Value="DarkBlue" /> <Setter Property="Foreground" Value="White" /> <Setter Property="LabelHighlight" Value="Black" /> </Style>
See screen capture below for the results of this style. I have ran into 2 roadblocks:
1) The filter, sort indicator, and pinned icons are too dark. How can I get l lighter versions of these icons to display? I know that the Onyx theme uses lighter versions of these icons. Can I control the icon colors w/out changing the theme?
2) I need to change the background color for columns that are sorted, since it now shows white text on top of a light blue background. How can I change the background color of sorted columns? Not applying any special style when the column is sorted would be fine as well.
I looked through the LabelPresenter style in \Program Files (x86)\Infragistics\2013.2\WPF\DefaultStyles\DataPresenter, but was not able to fiture out how to fix either of these problems.
Any help would be greatly appreciated. Tory.
Hello Tory,
Thank you for your post.
I have been looking into your requirements. About your first requirement, that I can suggest is to create style for LabelPresenter. In it you can handle the Loaded event of LabelPresenter by using EventSetter. In the event handler you can use our Utilities class to get the Sort Indicator and change its Background.
About your second requirement, that I can suggest is to create style for CellValuePresenter and LabelPresenter. In these styles, you can use Triggers and check the value of SortStatus property. You can set the Background and Foreground properties to the colors that you wish for each status.
Also if you want to be able to get the default style for LabelPresenter, you should search for it in the following directory on your computer:
C:\Program Files (x86)\Infragistics\2014.1\WPF\DefaultStyles\DataPresenter
You should search the style in file DataPresenterGeneric_Express.xaml. I created short sample application based on your scenario to show you how you can implement the functionalities that you are looking for. Please let me know if I am missing something about your scenario.
Please let me know if you need an further assistance on the matter.
Thanks Zhivko,
That all worked great! One final question. Is there an easy way to change the LabelPresenter style so that the background color is *not* change for sorted columns? It seems that some themes are configured to work like this (e.g. Onyx).
I have been looking into it. What I can suggest in order to be able to achieve the functionality that you want is to re-template the default style for LabelPresenter. You can find the default style for LabelPresenter on your computer on the destination:
C:\Program Files (x86)\Infragistics\2015.1\WPF\DefaultStyles\DataPresenter
You should search for the style in file DataPresenterGeneric_Express.xaml file. I modified the last sample application to show you how you can implement the functionality, that you are looking for. Basically I get the style and put it in the Resources of XamDataGrid. Then I change the Background and Foreground properties, for normal state. Also I set the same properties for SortStatus equal to Ascending and Descending states. If you want to change the background of Sort Indicator, you can find it in the style and set its Background property. If you want to stop the Highlighting of labels, you can find the animation named sbHighlightOn and comment it.
Please let me know if you need any further assistance on the matter.
Hi Zhivko,
That did the trick. Many thanks for your help!
Tory.
Thank you for your feedback.
I am very glad that my suggestion was helpful for your. Please let me know if you need any further assistance on the matter
So I do have one more question. When I take your LabelPresenter style, which is based on the Generic theme, I am able to tweak both the foreground and background colors of sorted labels, just like you showed in the sample app that you attached. However, when I try to do the same thing for the Aero theme, only the foreground color change is seen. Changing the background color has no affect.
In other words, if you take the Aero style and replace this:
<Trigger Property="SortStatus" Value="Ascending">
<Setter TargetName="SortIndicator" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="SortStatus" Value="Descending">
with this:
<Setter Property="Foreground" Value="LimeGreen" />
<Setter Property="Background" Value="DarkBlue" />
For sorted columns, you will see the foreground color change, but not the background color change. Do you know why? We prefer the look of the Aero LabelPresenter style over the Generic LabelPresenter, which is why I'm asking.