Skip to content

Using existing controls

anarchie347 edited this page May 15, 2023 · 2 revisions

Using existing controls

Themes comes with 3 built-in implementations of themeable controls: ThemeableButton, ThemeableLabel and ThemeableTextBox for Button, Lable, and text box controls in Windows Forms respectively.

Create an instance of one of the controls, and then set one of the themed properties. These themed properties will override the properties they correspond to (e.g. ThemeForeColor will override ForeColor).

When settings the properties using lambda expressions that reference wherever the current theme is stored (which is a property of the ThemeableForm<> class)

For example (This code is written inside the instance of ThemeableForm<>)

ThemeableButton btn = new ThemeableButton();
btn.ThemeForeColor = () => this.CurrentTheme.PrimaryColor
btn.ThemeBackColor = () => this.CurrentTheme.SecondaryColor
Clone this wiki locally