Hi, we're evaluating your WPF 15.2 product and have a few issues and questions.
In our app we have several xamdatagrids (about 14 at one time in a tab control) and we want to allow the users to change the theme for all the grids at once.1. When applying a theme through:Theme.Manager.SetTheme(xamDataGridName, new MetroTheme());The following exceptions are raised:A first chance exception of type: 'System.NotSupportedException' occured in PresentationFramework.dllA first chance exception of type: 'System.Xaml.XamlObjectWriterException' occured in system.Xaml.dllWhy is this happening and what can be done about this issue? With 14 grids we get this exception about 84 times...2.Performance - applying themes to all grids it takes about 20+ seconds. During this time the UI freezes up since it appears that Theme.Manager.SetTheme is running on the UI Thread. How can this time be improved? Can the themes be applied asynchronously or through databinding? If so, a basic sample with be greatly appreciated. 3. What's the recommended way to clear a theme?
If we in XAML set the metro theme for a xamdatagrid as such:
Theme="Metro" but then we want to clear the theme and we call Theme.Manager.SetTheme(xamDataGridName, null);
The theme does not get cleared.
Hello LA,
Thank you for your post.
I have been investigating into these issues that you are referring to, and I have some information for you on this matter. I will cover these issues in the order that you listed them in your original post.
1. I created a sample project of my own with quite a few XamDataGrids inside of a single tab in a XamTabControl, and I used the ThemeManager.SetTheme method to set the theme of each of these XamDataGrids to the Metro theme. This happened without any sort of exceptions on my end. Would it be possible for you to please provide some more detail as to when you are making the call to ThemeManager.SetTheme? Additionally, could you please provide some more information regarding the settings that you have placed on your XamDataGrid? Also, my tests were made against specific version 15.2.20152.2038 - does this match the version you are currently testing against?
2. When using the ThemeManager to apply themes to multiple objects, the ThemeManager goes out, grabs the theme files that are desired to be applied, and then applies them by merging them with the XamDataGrid's resources as a ResourceDictionary in this case. I'm not sure how you would be able to do this asynchronously, as the code called has an effect on UI elements, and so those elements are owned by the UI thread. However, you could possibly eliminate the need for the ThemeManager in this case, by including the theme files that the ThemeManager grabs in your project. Then, you could have a ResourceDictionary that points at this particular theme file and you could dynamically merge it. These theme files for the XamDataGrid can commonly be found in one of the few folders located at: C:\Program Files (x86)\Infragistics\<your version here>\WPF\Themes. Inside each of the folders at that directory, there will exist a .xaml file with the name "NameOfTheme.xamDataPresenter.xaml." I would recommend that you include this in your project and merge a resource dictionary with your XamDataGrids' Resources dynamically when you wish to apply your theme in this case.
3. Going off of the explanation given in point 2 (above), passing null into the "theme" parameter of the SetTheme method will not revert the XamDataGrid back to its default theme. The dictionaries that make up these themes are already merged at that point, and passing "null" into the SetTheme method does not "un-merge" these dictionaries. My recommendation for you to clear a theme in the XamDataGrid is to call myXamDataGrid.Resources.MergedDictionaries.Clear(). This will clear the dictionaries merged by your themes. Note, if you possibly have other dictionaries merged with your XamDataGrid, you may want to look into the MergedDictionaries collection for the correct one to remove, rather than clearing all of them.
I have attached a sample project to demonstrate points 2 and 3 above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hi,
Thank you for your reply. Based on your sample I can now set themes by adding resource dictionaries, which I didn't know how to do before.
I'm attaching an updated version of your sample that demonstrates the exception we're getting when setting themes through the ThemeManager.SetTheme as per your documentation @ http://help.infragistics.com/Help/Doc/WPF/2015.2/CLR4.0/html/themeManager_Applying_Theme_to_Control.html
Please check the Debug output for the exceptions raised by System.xaml.dll and PresentationFramework.dll
We'll go with your suggested method of adding resource dictionaries but since the official documentation shows a way that raises exceptions I would hope that gets addressed.
Thanks
I am glad that the resource dictionary merging solution that I had proposed seems to be working for you.
Regarding the exceptions that you are seeing, I believe this issue may be getting caused by a difference in our testing environments. I have tested the sample project that you recently attached against specific version 15.2.20152.2038 of Infragistics for WPF 2015.2, and I see no exceptions in the output window of Visual Studio or otherwise. Does this specific version match the one that you are using?
I have been doing some digging into our internal tracking systems and I did come across a bug that was fixed some time ago and released in 15.2.20152.2038. This issue reported a NotSupportedException and a XamlObjectWriterException being thrown when using the ThemeManager to set a theme. These exceptions appear to be synonymous with the ones you had originally reported in the first post to this forum thread. You had also said that you are using our 15.2 product, which leads me to believe that you are likely using a specific version in which this issue has not been fixed. If this is the case, I would recommend downloading and installing the service release for Infragistics for WPF 2015.2 by signing into your account and navigating to: https://ko.infragistics.com/my-account/keys-and-downloads. Then, you can select the 15.2 product that you are registered to, and select the resultant "Service Releases" tab to download 15.2.20152.2038.