Is there a way to load the style at design time (in visual studio)?
No, there's no way to load an ApplicationStyle at Design-time. You can create your style using AppStylist or you can style you live application using the AppStylistRunTime component.
Well, to be honest it is quite handy and I do not know why you don't include the functionality. But still, it is quite simple, here is a control that can load a style at design time. It will also load it at runtime, so you don't have to bother putting something to load it in your app main. This is edited for brevity.
Ok, thank you sir.
The above sample can be changed to simply use a Component instead of a UserControl, since you don't really need a control on the form to load the library. If you add a new Component to your project, add the Style property as mentioned above:
private string m_style;public string Style{ get { return m_style; } set { m_style = value; Infragistics.Win.AppStyling.StyleManager.Load(m_style); }}
After this build your component and add it to your form. Assigning the path of an ISL file was correctly reflected at design-time in my application.
-Matt
I don't know why Infragistics Mike is saying it can't be done, thats complete croc as i've been doing it since developing my current application ... starting 2 years ago??
The most common way to do this is to create a new form, i call it FrmDesignTimeAppStylist, inside it create an AppStylistRuntime control. You might have to reference the infragistics library.
One you've done this, open up the FrmDesignTimeAppStylist.Designer.vb (you might need to enable 'Show All Files') and inside the 'InitializeComponent' sub create the follwing line right at the end:
Me.AppStylistRuntime1.ShowRuntimeApplicationStylingEditor(Me, "test")
Save and Close the form.
Now everytime you load the form the app stylist will show, click load and select your style .. once loaded simply close the appstylist popup and your form ... the rest of your forms (and any you load) will have your styles loaded.
God knows why Infragistics have never put this in and i've seen many post by them saying it can't be done? Because the styles change absolutely everything including control sizes, it makes designing a complicated form near impossible unless you do this.
Oh, And if they ever take the functionality out to do this, my subscription will immediately end.
Very clever solution. :)
gone2mars said:God knows why Infragistics have never put this in
Note sure what you mean by that, exactly. Since this requires deriving your own special Form class, there's not much we can do there.
But if by "put this in" you mean put it into the docs or provide examples of this, it simply never occurred to me, personally.
The first post control works also, and doesn't require special forms.
But - honestly - has it really never occurred to you that we want to see what things look like while designing?
It's simple enough for some of us to write our own controls, or create our own forms, but for some people it's not that intuitive. Personally, I have used other controls from other vendors that had this functionality. I wasted half a day looking through documentation trying to figure out the "official and correct way" to get it done. It took 5 minutes to write the control above (and then an additional 2 hours to create a better one that would pull from the application dir or a central repository). I still wonder why this sort of thing isn't done in your control library itself.
jaimi said:But - honestly - has it really never occurred to you that we want to see what things look like while designing?
No, that's not what I said. I said it never occurred to me that you could show the AppStylistRun-time at design-time by deriving your own form. In fact, this approach is not completely new - it came up when we were designing the feature.
There are a couple of caveats to doing this, however. For one thing, if you are going to do this, you should make sure that only one form does it - or at least that only one form is open at a time. Otherwise, you will have two conflicting AppStylist libraries running at once and one could affect the other.
Another pitfall is that loading the AppStylist Runtime at design-time may affect the control designers.
Also, I don't think it will work on InBox control, since those controls require an InboxControlStyler and this component will not exist on the Form Designer itself at run-time.
These issues may not matter to you if you are writing a relatively simple application with a single form (or at least a single main form), but in a complex application where you are loading more than one form, or you have more than one project, or reference other assemblies that are not in the same solution, it can get very complex, vrey quickly.
The AppStylistRunTime was designed to let you run your application and style it while it is actually running and this allows you to style the Inbox controls, the Infragistics controls, save the library, load a library and everything else you would need to do to style your application. So it was not considered a high priority to allow styling at Design-time.