I am new the navigating this website and the Infragistics controls and was wondering how I can switch between StyleSets at runtime
I am loading my ISL file on application startup:
Dim defaultTheme As System.IO.Stream = executingAssembly.GetManifestResourceStream("MyApp.Default.isl")
If defaultTheme IsNot Nothing Then
Infragistics.Win.AppStyling.StyleManager.Load(defaultTheme)
End If
Oh, ok... Well I must be doing something wrong. Let me try and explain what I have and what I'm doing in order to achieve this goal.
I am storing a setting (My.Settings.UserThemePreference) that determines the style library to load on startup. I have create an Options form that alolows the user to select an alternative style ibrary and then I inform the user they must restart the application in order to apply the selected style library.
I would like to be able to change the theme when the user clicks to save the setting. How would I do this?
If it cannot be done by reloading a new style library, then explain how it can be done using a style set. I tried using style sets initially by changing the DefaultStyleSetName property of the StyleManager in a hope that would inform all the Infragistic controls of the change - is my assumption incorrect here?
Many thanks.
Hi Phil,
I'm still not sure I understand what you are asking.
The Infragistics WinForms controls resolve their appearances in a multi-step process involving the settings on the control's Appearance properties and the currently-load application style library in memory.
When you load a StyleLibrary using StyleManager.Load, the controls are notified that something has changed any they update their displays.
You can't load a single StyleSet - the StyleSets are part of the StyleLibrary. But you can load a new StyleLibrary into memory. You are already doing this in your code when you call StyleManager.Load. If you want to load a new StyleLibrary, you just call the same method again and pass in a different library file. In fact, there's a sample included with the NetAdvantage SDK that demonstrates doing exactly this.
What part of this are you having trouble with?
I am trying to make my application work like Themes do in WinXP. I want to be able to have a selection of themes that when the user selects on it will apply the necessary style library or set (not bothered which) to all the Infragistic controls currently loaded.
I was hoping the StyleManager was publishing an event to all the Infragistic controls that would load the new style set selected. If I have to loop through all the Infragistics controls myself, then I'll simply put a message up saying the user must restart the application for the theme to take affect.
I'm not sure I follow what you are trying to do. It looks like your first example is changing the BackColor of the form. No property settings on the form or any controls will affect the style. The Style will, in fact, override these settings.
If you want to load a new StyleLibrary into your application, then you would just call StyleManager.Load and pass in a different file.
If you want to modify the StyleLibrary currently in memory in code, then this is quite complex and difficult. You would have to change the colors on a huge range of UIRoles to get your whole application to be consistent. It is possible to do this in code, though, if you really want to try it.
Here's a post that deals with something very similar, changing the font: Change font at runtime - Infragistics Forums
I've done some more digging and I tried this:
If String.IsNullOrEmpty(Infragistics.Win.AppStyling.StyleManager.DefaultStyleSetName) _
OrElse Infragistics.Win.AppStyling.StyleManager.DefaultStyleSetName.Equals("Default") Then
Infragistics.Win.AppStyling.StyleManager.SetDefaultStyleSetName(Nothing, "White")
Else
Infragistics.Win.AppStyling.StyleManager.SetDefaultStyleSetName(Nothing, "Default")
[NameOfInfragisticsControl].StyleSetName = "White"
[NameOfInfragisticsControl].StyleSetName = String.Empty
This is no good for me as I want to be able to change the background (for example) by a single click for all Infragistics controls.