๐Ÿ”น Kt-CheckButton

Overview

KtCheckButton is a modern, customizable toggle button control that combines the functionality of a checkbox with the visual appearance of a button. It provides rich styling options including gradients, icons, and smooth state transitions, making it ideal for creating engaging user interfaces in Windows Forms applications.


Key Properties

Property
Type
Default
Description

Checked

bool

false

Gets or sets whether the button is in checked/toggled state

Text

string

""

The text displayed on the button

Icon

string

""

Icon identifier for unchecked state

Icon_Checked

string

"tabler.solid.circle_check_filled"

Icon identifier for checked state

Background

KtBrush

Gradient

Background brush for unchecked state

Background_Checked

KtBrush

Solid

Background brush for checked state

Border

KtBrush

Gradient

Border brush for unchecked state

Border_Checked

KtBrush

Solid

Border brush for checked state

BorderRadius

float

10

Roundness of button corners

BorderWidth

float

2

Thickness of the border

Foreground

KtColor

Empty

Text/icon color for unchecked state

Foreground_Checked

KtColor

Empty

Text/icon color for checked state

IconSize

int

16

Size of the icon in pixels

IconStroke

double

2.5

Stroke width for icon rendering

TextAlign

ContentAlignment

MiddleCenter

Alignment of text within button

ImageAlign

ContentAlignment

MiddleLeft

Alignment of icon within button

TextMargin

int

0

Spacing between text and icon

Padding

Padding

7,7,7,7

Internal padding of button content


Events

Event
Description

CheckedChanged

Fires when the Checked property changes


Basic Usage

Simple Toggle Button

Button with Icon


Styling Examples

Gradient Background

Solid Color with Custom Border

Minimalist Style


Advanced Features

Custom Icon Colors

Text and Icon Alignment

Programmatic Control


Common Patterns

Toggle Group (Radio-like Behavior)

State Indicator

Animated Theme Toggle


Design Tips

  1. Consistency: Use the same BorderRadius across related buttons for visual cohesion

  2. Icon Selection: Choose icons that clearly represent both states (e.g., play/pause, on/off)

  3. Color Contrast: Ensure checked and unchecked states are visually distinct

  4. Hover Effects: The control automatically provides hover feedback

  5. Accessibility: The button defaults to a hand cursor to indicate interactivity


Performance Notes

  • Use SuspendLayout() and ResumeLayout() when making multiple property changes

  • The Render() method is automatically called on property changes

  • Icon rendering is cached for performance


  • KtCheckBox: Traditional checkbox with advanced styling

Last updated

Was this helpful?