RadToggleSwitchButton: The animation of the thumb switch updates its position when the animation finishes. This happens with a slight delay. However, if the animation is disabled, this delay should not be executed. Instead, the thumb should be updated immediately.
Currently, the delay can causes an animation-like effect in some specific situations.
To work this around, you can create a custom RadToggleSwitchButton and override the property changed callback of the IsChecked property.
public class CustomToggleSwitchButton : RadToggleSwitchButton
{
private FrameworkElement thumb;
static CustomToggleSwitchButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomToggleSwitchButton), new FrameworkPropertyMetadata(typeof(CustomToggleSwitchButton)));
IsCheckedProperty.OverrideMetadata(typeof(CustomToggleSwitchButton), new FrameworkPropertyMetadata(OnIsCheckedPropertyChanged));
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.thumb = this.GetTemplateChild("PART_Thumb") as FrameworkElement;
}
private static void OnIsCheckedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var switchButton = (CustomToggleSwitchButton)d;
if (switchButton.thumb == null)
{
return;
}
bool? isChecked = e.NewValue as bool?;
if (isChecked == true)
{
switchButton.thumb.HorizontalAlignment = HorizontalAlignment.Right;
}
else if (isChecked == false)
{
switchButton.thumb.HorizontalAlignment = HorizontalAlignment.Left;
}
else if (switchButton.IsThreeState)
{
switchButton.thumb.HorizontalAlignment = HorizontalAlignment.Center;
}
}
}