Hello...
I would like to change the theme of an application at runtime.
In order to achieve this effect I use the ThemeManager "CurrentTheme" Property .
( Already shown in another Thread.)
How may I now access custom Themes or themes which are not predefined in ThemeManager.GetThemes. In example "Lipstick" or "Leaf" ...
I'm a WPF newbee ... Any help is highly welcome.
Thanks,
Daniel
Hello,
In order to set a theme runtime of the existing ones. You just need add the assembly of that theme to your project and use the appropriate style for the component you need. For example you can load the theme for DataPresenter in the constructor or in the loaded event: eInfragistics.Windows.Themes.Lipstick.DataPresenter presenter = new Infragistics.Windows.Themes.Lipstick.DataPresenter();
And simply set current theme in any action for example button click:ThemeManager.CurrentTheme = "Lipstick";
I hope this helps.
Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.
Hello Dimi,
thanks for the quick answer!
Dimi Gineva"] You just need add the assembly of that theme to your project and use the appropriate style for the component you need.
Adding the assembly to my existing project does not seem to work. I still can't use the theme or set the style for a Ribbon Control.
ThemeManager.SetTheme(Ribbon,"Lipstick") doesn't work.
Also the theme isn't part of ThemeManager.GetThemes() ... ThemeManager.CurrentTheme = "Lipstick" leads to "Theme has not been registered".
In the short demo I found in this forum after referencing the assemby everything works just fine ... I'm quite confused at the moment.
Hello , You got the error because you don’t use Infragistics.Windows.Themes.Lipstick.DataPresenter presenter = new Infragistics.Windows.Themes.Lipstick.DataPresenter(); If you are using existing build in Theme you can directly set it by using his name :ThemeManager.CurrentTheme = ThemeManager.ThemeNameLipstick;Or ThemeManager.CurrentTheme = "Lipstick";I have attached sample for your convenience.Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.
Just to add to what Dimi said, basically GetThemes returns a list of the themes that have been loaded. If nothing is referencing a type in an assembly (e.g. in one of the theme pack assemblies like Lipstick) then the CLR will not load that assembly. You would need to reference a type in the theme assemblies. There is an example of this mentioned here.
Hello ... sorry for bothering you again ...
Dimi Gineva"] You got the error because you don’t useInfragistics.Windows.Themes.Lipstick.DataPresenter presenter = new Infragistics.Windows.Themes.Lipstick.DataPresenter();
thanks for your timeDaniel
Hello, I am confused in your sample you didn’t add the references to the Lipstick theme, also I didn’t see any loaded type of the theme. I have modified your sample with my last suggestions and was successfully applying the selected style with from the list. I have tested with all build in themes and everything was working fine, without any error. Please look at the modified sample.Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.
sorry for the confusion ... the sample I added wasn't the application in question. It was a demo from Alex Fidanov. I was wondering why it was working perfectly only with a reference to an assembly and
WITHOUT
Infragistics.Windows.Themes.Lipstick.DataPresenter presenter = new Infragistics.Windows.Themes.Lipstick.DataPresenter();
You can try it and just add e.g. the reference to Lipstick.dll ...
As I wrote above my project doesn't work with
It throws throws the error I mentioned above. Sorry I'm taking so much time ...
Hi Daniel,
Could you provide sample code or a project in which you're receiving this error? We can investigate your issue further with that. Thanks.
Sincerely,Duane
Hello Duane,
I'm still searching my application for the reason of the above mentioned error message:
By accessing the style property for Element "Infragistics.Windows.DataPresenter.XAMDataGrid" a circular reference was found.
Couln't find an answer so far ...
I just wanted to know if we're able to answer your questions and you still need help? Just let me know. Thank you.
Maybe you have a Style where you are trying to set the Theme property? You should not set the Theme property via a Style setter, etc.
Thanks a lot for your answers,
you were right ... the "hosting process option" in my project was unchecked. After referencing a type in an theme assembly these assemblies were loaded as I could see in ThemeManger.GetThemes().
Unfortunately using e.g. ThemeManager.Current ="Fall" got me a Runtime Exception:
"By accessing the style property for Element "Infragistics.Windows.DataPresenter.XAMDataGrid" a cyclic reference was found."
Searching now through my resources to solve the problem ...Perhaps you've got a suggestion?