[]
        
(Showing Draft Content)

Styling and Themes

You can change the appearance of the menu in two ways. Apply a ComponentOne theme to restyle the menu together with the other controls on the form, or use the Styles property to adjust the borders, fonts, padding, colors, and badges of the menu directly.


Apply a Theme

C1ThemeController applies the theme you choose to the menu and to the other supported ComponentOne controls in the control tree. As a result, the whole form keeps a consistent appearance.

The following example applies a theme to the controls in a form or user control:

using C1.Win.Themes;

internal void ApplyTheme(C1Theme theme)
{
    C1ThemeController.ApplyThemeToControlTree(this, theme);
}

Note: ApplyStyle and ThemeChanged provide lower-level theming support. Most applications should apply themes through C1ThemeController.


Customize Menu Styles

Use the Styles property to configure the borders, fonts, padding, state colors, and badge appearance of the menu.

The following example sets the border, font, and padding of the toggle button, the items, and the active item, and sets the badge shape for three item states. The example needs the System.Drawing and C1.Framework namespaces.

var font = new Font(new FontFamily("Arial"), 12, FontStyle.Bold, GraphicsUnit.Pixel);

menu.Styles.Common.ShowBorder = true;

menu.Styles.ToggleButton.Border = 1;
menu.Styles.ToggleButton.Font = font;
menu.Styles.ToggleButton.Padding = new Thickness(8);

menu.Styles.Items.Border = 1;
menu.Styles.Items.Font = font;
menu.Styles.Items.Padding = new Thickness(8);

menu.Styles.ActiveItem.Border = 1;
menu.Styles.ActiveItem.Font = font;
menu.Styles.ActiveItem.Padding = new Thickness(8);

menu.Styles.Items.Default.Badge.Shape = BadgeShape.RoundedRectangle;
menu.Styles.Items.Hot.Badge.Shape = BadgeShape.Circle;
menu.Styles.Items.Disabled.Badge.Shape = BadgeShape.RoundedRectangle;

The following table describes the available style groups:

Style

Applies To

Common

The menu container, including its default background, border, and font settings.

Items

Menu items in the Default, Disabled, Hot, Pressed, and Highlighted states. The Highlighted state applies to search matches.

ActiveItem

The currently selected menu item.

ToggleButton

The hamburger button in the Default, Disabled, Hot, and Pressed states.

Items.<state>.Badge

Item badges. This style configures badge shape, font, border, and colors.

Items.<state>.Parent

Menu items that contain child items.

Set the menu-level BackColor property to change the menu background. Use BackColor and ForeColor within a style state to configure state-specific colors. Badge styles also expose BorderColor.

Properties shared across all states, such as Border, Font, and Padding, are set on the style group. State-specific colors are configured on the corresponding state. Padding and Margin use C1.Framework.Thickness values, and Border specifies the border thickness.