Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
Can I use the isl file format to load a partial file containing only modifications to the current style
posted

I'd like to have some variations on the Default style, mainly changes in the title color. I do not want to maintain an ISL file for each title color.

Is there a way to load Default.isl and then load a second isl file containing only the differences with Default.isl

I created a file TitleGreen.isl with following contents

<?xml version="1.0" encoding="utf-8"?>
<styleLibrary>
  <styleSets>
    <styleSet>
      <styles>
        <style role="ToolbarDockAreaTop">
          <states>
            <state name="Normal" backColor="54, 164, 0" backGradientStyle="None" backHatchStyle="None" />
          </states>
        </style>
        <style role="MainMenubarHorizontal">
          <states>
            <state name="Normal" backColor="54, 164, 0" backGradientStyle="None" backHatchStyle="None" />
          </states>
        </style>
      </styles>
    </styleSet>
  </styleSets>
</styleLibrary>



but when I try to load this file I get "Invalid XML" An error occurred while trying to load the specified file. Would you like to load it anyway, ...

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Carl,

    There's no way to load a partial isl file - at least not into the StyleManager. But an isl file is ultimately Xml, so in theory, you could load your partial isl file as text or as an XmlDocument and then write code to manually do the merging in the original isl, then save that modified isl as a file and load it into the StyleManager. But there's no automatically merging, so you'd have to write the code to parse the new (partial) isl and then find the matching tags in the existing one and add/replace them. I suppose you might also search to see if there is some third-party utility that will do the merging for you. I'm not aware of any, but I've never looked for one. :)

    There are a couple of other approaches you could take that would probably be easier.

    Approach 1 - using StyleSets

    One approach would be to use StyleSets. I'm not sure how far you've delved into creating Style Libraries. But a single library can contain one or more StyleSets. When you create a new Library, it adds a Default StyleSet by default. But you could add a new StyleSet to your Library and set it so it's "Based On" the default StyleSet. Then you can simply make the changes you want to that particular StyleSet and anything you set on it will override the Default StyleSet settings for controls using that StyleSet.

    The down side of this approach is that you still have to set up a StyleSet for each color (or set of colors) that you want to have available in your application. So it doesn't require a whole new Isl file, but it does mean you have to set up a bunch of StyleSets. Also, this means that when you want to change the color(s), you have to find all of the relevant controls/components in your application and set the StyleSetName property on each one. If it's just one UltraToolbarsManager, then that's probably not a big deal. But if you have a lot of controls, this could be a pain.

    Approach 2 - using code

    Another option would be to set the colors on the StyleLibrary currently in-memory using code. This is a bit tricky, but it's more flexible, since you can plug in any color(s) you want without having to pre-define them in any isl files. And you don't have to do anything to any of your controls.

    I have attached a sample project here that demonstrates both approaches. The sample includes an isl file with a very simple default StyleSet and a second StyleSet ("New StyleSet 1') that overrides the BackColor on the Normal State of the ToolbarDockAreaTop role. So when you click the button, it just toggles the StyleSetName on the ToolbarsManager and the color changes.

    Also, a second button changes the color of the Normal State of the ToolbarDockAreaTop via code. Let me know if you have any questions.

    Changing Style Library Colors at Runtime.zip

Reply Children
No Data