Skip to main content
All docs
V19.1

Style Controller

  • 3 minutes to read

The StyleController component allows you to manage the look and feel and appearance settings of multiple BaseControl descendants (including editors). Add a StyleController component to a form, modify the settings it exposes and then assign the StyleController to the BaseControl.StyleController properties of target controls.

StyleController-Component.png

Override the Style Controller’s Appearance Settings for Individual Editors

By default, all editors bound to a StyleController use the same appearance settings exposed by the StyleController. Modify the appearance settings an editor exposes to override the default appearance settings.

StyleController-cd-editor-appearance-settings.png

Tip

To learn how to customize the look-and-feel settings of controls, see Look And Feel and Skinning.

Example

Assume that a style controller should provide common appearance and look and feel settings for a text editor, button editor and listbox control. The style controller is customized as follows:

CD_StyleController_Ex_StyleCOntroller_prop

Next, the style controller should be assigned to the controls. In the following image it is assigned to a text editor:

CD_StyleController_Ex_AssignStyleController

Now, if you run the application the controls will look like those displayed in the image below:

CD_StyleController_Ex_Intermediate_Result

Suppose the text color in the text editor should be different than the common color exposed by the style controller. To do this you only need to set the text editor’s Appearance.ForeColor property to the required value:

CD_StyleController_Ex_TextEdit_SetForeColor

The final result of the customization is shown below. Note that the background color of a text editor is not affected by the modification of the editor’s Appearance.ForeColor property. The background color is still retrieved from the style controller.

CD_StyleController_Ex_Result

For detailed information on the Appearance mechanism refer to the Appearances document.

The following code is equivalent to the design-time customization actions illustrated above:


// Set the foreground color of the text editor.
textEdit1.Properties.Appearance.ForeColor = Color.BlueViolet; 
// Bind the controls to the style controller.
textEdit1.StyleController = styleController1;
buttonEdit1.StyleController = styleController1;
listBoxControl1.StyleController = styleController1;
// Customize the style controller's appearance settings.
styleController1.Appearance.BackColor = Color.LightYellow;
styleController1.Appearance.Font = new Font("Tahoma", 8);
styleController1.Appearance.ForeColor = Color.SaddleBrown;
// Customize the style controller's look and feel settings.
styleController1.LookAndFeel.UseDefaultLookAndFeel = false;
styleController1.LookAndFeel.UseWindowsXPTheme = false;
styleController1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Flat;
See Also