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
PhilAI said:I was hoping to stick to a single style library
Then use a resource, instead.
OK - I was hoping to stick to a single style library; then I have one per theme. I have decided to set the Override.RowAppearance properties, and then in the BeforeRowExpanded event I am updating the Appearance of each row to match this Appearance. A good temporary solution for now considering the only styling we wish to apply is to the row.
If we get many requests for changing the colour of this row in the future, then I'll create multiple libraries.
AppStylist styles the whole application. It doesn't have any context for a specific band by itself.
But there is a way you can do it. The Appearance object has a couple of useful properties for cases like this:
StyleLibraryName and StyleResourceName.
StyleLibraryName allows you to specify that the appearance of the object should come from a particular style library. You specify some arbitrary string of your own choosing. Then you load a style library into memory and make sure you use the overload of StyleManager.Load that takes a name. So basically, you load two different style lirbaries into memory. Most controls will just use the default library (the one without a name). The named library will only be used by controls that have their StyleLibraryName set to the same name or any appearances that likewise are using the same name.
If you don't want to create a whole new style library, then you could just create a Resource in the existing StyleLibrary and specify the StyleResourceName. Then the appearance will pick up it's settings from that resource.
I have no idea what I was doing wrong before, but I managed to get the styles updating by loading the selected style library at runtime. Now I have a new question related to the AppStylist...
Can you use AppStylist to set a row appearance for each band level within an UltraGrid? For example, I have a grid with two bands: Item and Payment. I want Item to be styled using my default settings for GridRow, and Payment to be defined with a different set of colours. I have used the Override options within the Payment band to define the row colour I want, but AppStyling is overriding my Override settings - is this correct behaviour or do I need to define my 2nd band row colours elsewhere?
Thanks again.
PhilAI said: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.
FYI - you do not have to restart the application in order to load a new StyleLibrary.
PhilAI said:If it cannot be done by reloading a new style library, then explain how it can be done using a style set.
I beleive I have stated at least a couple of times in this thread already that you can load another style library into memory any time you like by calling StyleManager.Load. I'm not sure where the confusion is coming in here or how I can make this any clearer.
Are you saying that this is not working for you? Have you looked at the sample I mentioned to get a demonstration of how this is done?