Siticone Toggle Switch
The SiticoneToggleSwitch is a modern replacement for the traditional CheckBox, often used for activating features or preferences.
It features a customizable sliding thumb with fluid animations, gradient tracks, and built-in support for state labels ("On"/"Off").
State Management
Control the switch's state and handle interaction restrictions.
| Property | Type | Description |
|---|---|---|
Checked |
bool |
The main property to get or set the switch state.
Synonymous with IsOn.
|
IsReadOnly |
bool | If true, the switch cannot be toggled by the user, but retains its visual style (unlike Enabled=false). |
PreventToggleOff |
bool | If true, the switch can be turned ON, but cannot be turned OFF by the user once active. |
DisallowToggling |
bool | Completely locks the toggle interaction, triggering feedback (Shake/Beep) if clicked. |
Visual Customization
Every part of the switch (Track, Thumb, Border) supports dual-color gradients for both ON and OFF states.
| Property | Type | Description |
|---|---|---|
OnBackColor1/2 |
Color | Gradient colors for the track when the switch is ON. |
OffBackColor1/2 |
Color | Gradient colors for the track when the switch is OFF. |
OnThumbColor1/2 |
Color | Gradient colors for the circular thumb when ON. |
OffThumbColor1/2 |
Color | Gradient colors for the circular thumb when OFF. |
ThumbSizeRatio |
float | Ratio of the thumb size relative to the control height (0.1 to 1.0). Default is 0.7. |
ThumbShape |
Enum |
Circle or Square geometry for the sliding thumb.
|
Animation Physics
The control features two distinct animation styles for the thumb movement.
| Property | Type | Description |
|---|---|---|
ThumbAnimationMode |
Enum |
Fluent: The thumb stretches fluidly like liquid during movement. Graceful: The thumb maintains a stretched shape during travel and shrinks upon arrival. |
EnableThumbStretch |
bool | Enables the horizontal stretching effect during animation. |
StretchFactor |
float | Controls how much the thumb elongates during the animation (0.1 to 1.0). |
OnAnimationSpeed |
int | Duration (ms) for the switch-on animation. |
Labels & Icons
Display text or icons inside the switch thumb or track.
| Property | Type | Description |
|---|---|---|
ShowLabels |
bool | Toggles the display of "On"/"Off" text inside the track. |
OnLabel |
string | Text displayed on the left side when the switch is ON. |
OffLabel |
string | Text displayed on the right side when the switch is OFF. |
OnIcon |
Image | Icon displayed inside the thumb when ON. |
OffIcon |
Image | Icon displayed inside the thumb when OFF. |
Events
// Fired when the toggle state changes.
toggleSwitch.CheckedChanged += (s, e) =>
{
// e.IsOn indicates the new state
if (e.IsOn)
{
EnableFeature();
}
else
{
DisableFeature();
}
};
// Fired before the state changes. Allows cancellation.
toggleSwitch.StateChanging += (s, e) =>
{
if (e.NewState == true && !IsUserAdmin())
{
e.Cancel = true;
MessageBox.Show("Admin rights required.");
}
};
Designer Support
The control includes a comprehensive Smart Tag menu.
| Category | Features |
|---|---|
Themes |
Apply presets like Light, Dark, Material, iOS 15, Neon, etc. |
Animation |
Configure Speed, Thumb Animation Mode (Fluent/Graceful), and Stretch Factor. |
Behavior |
Toggle ReadOnly, Ripple Effects, and Sound paths. |
Usage Examples
Example 1: Standard Settings Toggle
A basic switch for app preferences.
private void SetupSettingsSwitch()
{
toggleNotifications.Checked = true;
// Use built-in iOS Theme
toggleNotifications.ApplyiOS15Theme();
toggleNotifications.CheckedChanged += (s, e) =>
{
Properties.Settings.Default.NotificationsEnabled = e.IsOn;
Properties.Settings.Default.Save();
};
}
Example 2: Custom "Power" Switch
Creating a distinct look with icons and specific colors.
private void SetupPowerSwitch()
{
powerSwitch.ThumbSizeRatio = 0.9f; // Large thumb
// Colors
powerSwitch.OnBackColor1 = Color.LimeGreen;
powerSwitch.OffBackColor1 = Color.DimGray;
// Icons
powerSwitch.OnIcon = Properties.Resources.icon_power_on;
powerSwitch.OffIcon = Properties.Resources.icon_power_off;
// Animation
powerSwitch.ThumbAnimationMode = ThumbAnimation.Graceful;
powerSwitch.StretchFactor = 0.5f;
}
Example 3: Restricted Access Toggle
Using the StateChanging event to prevent changes based on logic.
private void SetupAdminToggle()
{
toggleAdminMode.StateChanging += (s, e) =>
{
if (e.NewState == true) // Trying to turn ON
{
if (!CheckAdminPassword())
{
e.Cancel = true;
// Trigger shake feedback manually if needed
toggleAdminMode.TriggerShake();
}
}
};
}
Example 4: Logger Integration
Using the IToggleSwitchLogger interface to track usage.
// Define a simple logger class
public class DebugLogger : IToggleSwitchLogger
{
public void Log(string message)
{
Debug.WriteLine($"[SWITCH] {DateTime.Now}: {message}");
}
}
// Assign to control
private void InitControl()
{
siticoneToggleSwitch1.Logger = new DebugLogger();
}