Skip to main content
A newer version of this page is available. .

Appearance Inheritance Options

  • 3 minutes to read

The XtraBars suite allows you to inherit appearance settings, the subject of this topic. Inheriting appearance options means that if the parent’s appearance settings are changed this will immediately be reflected by all its children.

Appearance Inheritance in XtraBars

By default, the appearance and customization settings for all the dock controls and bars within your application’s forms are provided by the Default BarAndDocking Controller. If you need to provide different settings for the dock controls and bars that belong to a particular dock manager/BarManager, you should use the BarAndDockingController component. Finally, to give an individual bar or dock control the desired look, you should override the BarAndDocking Controller’s appearance settings using the appearance inheritance options provided by the appearance objects.

The image below illustrates the appearance inheritance structure.

AppearanceOptions_03

Settings inherited from the BarAndDocking Controller are specified by the options listed in the AppearanceObject.Options property. You should disable options that correspond to inherited appearance settings. For example, if you need to use the controller’s foreground color, set the AppearanceOptions.UseForeColor property to false. For detailed information on appearance options, see the AppearanceOptions class description.

The following table lists the available appearance options.

Option Description
AppearanceOptions.UseBackColor Gets or sets whether to use the AppearanceObject.BackColor property value.
AppearanceOptions.UseBorderColor Gets or sets whether to use the AppearanceOptions.UseBorderColor property value.
AppearanceOptions.UseFont Gets or sets whether to use the AppearanceOptions.UseFont property value.
AppearanceOptions.UseForeColor Gets or sets whether to use the AppearanceOptions.UseForeColor property value.
AppearanceOptions.UseImage Gets or sets whether to use the AppearanceOptions.UseImage property value.

Using Appearance Options

Let’s consider an example of using appearance options when customizing bars.

When a new Bar object is being initialized, its Bar.Appearance property is automatically set to a new AppearanceObject instance. By default, all appearance options are disabled, and the bar’s appearance settings are determined by the BarAndDockingController assigned to the Bar Manager that owns the current bar. This controller provides the appearance and customization options for the bars belonging to the current BarManager. If the BarAndDocking Controller is not specified (the BarManager’s BarManager.Controller property is set to a null reference), the appearance settings are specified by the default BarAndDocking Controller.

Please refer to the Bar and Docking Controllers (Customizing Default View and Behavior Settings) topic for detailed information on using the BarAndDocking Controller.

The image below shows the bFile bar’s look and feel. The background’s settings are inherited from the BarAndDocking Controller’s bar appearance settings.

AppearanceOptions_01

To override the BarAndDocking Controller’s appearance settings for an individual bar, you should set the bar’s desired appearance properties to true. The image below shows how to override the BarAndDocking Controller’s background settings.

AppearanceOptions_02

The sample code below demonstrates how this can be performed via code.


using System.Drawing.Drawing2D;

bFile.Appearance.BackColor = Color.Gray;
bFile.Appearance.BackColor2 = Color.White;
bFile.Appearance.GradientMode = LinearGradientMode.Vertical;
bFile.Appearance.Options.UseBackColor = true;
See Also