Hi, I want to use one of your themes (RoyalDark) in my solution, but I want to do some minor modification to the theme, such as colors. I've tried the Resource Washer, but that adds color to way too many elements and does not look good.
I've tried using Theme="RoyalDark" and customize the style locally in the XamDataGrid.Resources, but it's not a suitable way because there will be a lot of code duplication since I have many datagrids in my solution.
I've also tried adding the RoyalDark-resources from the theme folder to my solution and the App.xaml and then editing the colors in the resource files (i.e. DataPresenterRoyalDark_Brushes.xaml). This works, but it seems exaggerated when I just want to make small changes to the theme. It is also harder to keep track of my customizations to the original theme. I found a example in your documentation, 'Extending an Existing Control Theme', which sounds like exactly what I'm looking for.https://es.infragistics.com/help/wpf/thememanager-extending-existing-control-theme
The example shows how to do it with XamTileManager, but I'm trying to get this technique working for XamDataGrid, since I have a lot of those in my solution.Following the example, I based my custom theme on the RoyalDark theme:
public class RoyalExtendedTheme : RoyalDarkTheme
And then override the mapping of XamDataGrid with a XAML resource-file I created:
Mappings[ControlMappingKeys.XamDataGrid] = ThemeBase.BuildLocationString(assemblyFullName, @"/Themes/RoyalExtendedTheme.Colors.xaml");
The XAML resource-file just consist of three colors, which targets the "accent" colors of the theme, identified in the theme resources "DataPresenterRoyalDark_Brushes.xaml" and "Theme.Colors.xaml":
<Color x:Key="Color_011">#FF00b6f1</Color> <!--BG SELECTED/PRESSED/CHECKED--> <Color x:Key="Color_013">#FF00b6f1</Color> <!--BrD FOCUS--> <Color x:Key="Color_0013">#FF00b6f1</Color> <!--Hyperlinks Normal-->
The theme is then applied to a XamDataGrid:
<igDataPresenter:XamDataGrid BindToSampleData="True"> <ig:ThemeManager.Theme> <themes:RoyalExtendedTheme /> </ig:ThemeManager.Theme> </igDataPresenter:XamDataGrid>
This do not work, no sign of the modified colors and the style of the XamDataGrid seems to mostly be the generic theme. Please see screenshot below.
Removing the colors from the XAML resource-file and making it empty produces the same result. So I'm guessing it has to be something with the XamDataGrid mapping override.
So the question is: How do you override the XamDataGrid mapping in order to make this work?Since XamDataGrid is of the DataPresenter family, should my extended theme be based on Infragistics.Windows.Themes.DataPresenterRoyalDark? If so, how - it's a DataPresenterResourceSet and not a BuiltInThemeBase?Must the XAML resource-file contain all of the DataPresenterRoyalDark-resources not just part's of it?
Please see my attached sample-solution.
6204.ExtendTheme.zip
Hi,
Thanks for the example. There are still some parts of the XamDataGrid which are of generic theme, so I give up following this technique.
I will settle on either merging the theme resource files in the XamDataGrid.Resources as you proposed in your first answer or most likely I will include them in my application App.xaml, which will be more of a implicit styling of the XamDataGrids.
Hello Asle,
I have been discussing this behavior with my colleagues, and just including brush resources is not guaranteed to work in this case, as if the brushes are used as StaticResources within the base theme, they will not be used as there is nothing to actually resolve them from that file.
The best recommendation I can make in this case is to include the ResourceDictionary that represents the base theme and merge it with the ResourceDictionary that you will point the BuildLocationString at.
I am attaching a modified version of the sample project you had originally sent to demonstrate this. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
3386.6204.ExtendTheme.zip
Thank you for the answer.
Regarding the 'extending an existing control theme'-technique:When adding all the colors which actually uses the accent colors to the BuildLocationString-file, it still have no effect. I.e.:
<SolidColorBrush x:Key="CellVPBackgroundActive" Color="{StaticResource Color_011}" />
Is it even possible to use this technique for XamDataGrid?To rephrase the question; Can you give an example of how to extend/modify a theme to the XamDataGrid control given the technique in your documentation?
Hell Asle,
I have been investigating into the behavior that you are referring to, and it appears that the issue with this is that the only colors that are specified are the ones that are used in the cell’s edit mode-related functionality. In order to have all of the colors specified, I believe you will need to include them with the file that the BuildLocationString is pointed to in this case.
There are a couple of alternate recommendations that I can make on this matter as well. You mentioned that you do not want to write the styles in the Resources section of the grid, but have you considered putting these styles within a ResourceDictionary and then just merging that dictionary with your grids? This still requires some code to go into the XamDataGrid.Resources section, but it is about the same amount as setting your custom theme in this case.
Another option is to simply include the relevant theme files and then merge them with the XamDataGrid.Resources section. These can be obtained from the C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\DataPresenter directory, and the relevant files will be named DataPresenter<ThemeName>.xaml and DataPresenter<ThemeName>_Brushes.xaml. If you include these, make your modifications to them, and then merge them with the resources of your grid, this may be easier than tracking down all of the brushes that you would need.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.