views:

1108

answers:

1

I am using DevExpress controls in a winform app I am building for internal use. My app has about 30 forms in total and I am trying to figure out a way to allow my user's to select a theme. I have seen this mentioned here at SO multiple times in answers to other posts.

I understand how the StyleController works, I believe, but what I am wondering is how I can use 1 Style controller for the whole app.

Right now I am trying to create 1 StlyeController at the Shell form and then pass a reference to it to each child form. From there I then have to programatically set the StyleController property for each control. I don't mind I just wonder, especially from those who have done this, if there is a simpler way?

+2  A: 

It is very simple. This example is assuming that you are using skins.

In the constructor of your main form calls:

DevExpress.Skins.SkinManager.EnableFormSkins();

This will enable your form to use the current skin. It is also important that each of your forms derived from XtraForm.

After that you need to setup the global look and feel object for your application:

//This set the style to use skin technology
DevExpress.LookAndFeel.UserLookAndFeel.Default.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;

//Here we specify the skin to use by its name     
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Black");

If you want to set the look and feel of your application like Office 2003, the setup is different. You just have to call the following function:

DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style();

So, every control of devexpress will use these settings to paint themselves. It is possible to specify a custom LookAndFeel object for some controls but I never used it because I dont see the point to have a custom display for a control or a form.

Exception: There is one exception in Devexpress framework. The NavBarControl does not use the skin technology automatically from your global LookAndFeel object, you need to specify a setting to enable that:

//To use the current skin
youNavBarControl.PaintStyleName = "SkinNavigationPane";

//To use the current look and feel without the skin
youNavBarControl.PaintStyleName = "NavigationPane";
Francis B.
I am probably taking this way to literal but in --> (MyConfiguration.SkinName); what does MyConfiguration represent?
Refracted Paladin
Sorry, I used MyConfiguration to simply the code. In my case MyConfiguration represents a class which holds the configuration information of my application and therefore the skin name to use at the startup of the application. You can replace MyConfiguration.SkinName by your own string or if you want to test your code right away you can use the following string : "The Asphalt World", "Blue", "Black", "Caramel" or "Lilian" which are base skin name coming with DevExpress.
Francis B.