I have a CheckBox in my application that is using the TriState mode. The normal behavior for this mode seems to be cycling between null, false, true.
I\'d like to c
Thank you very much, it has been very useful to solve a similar behavior with ToggleButton.
class InvertedToggleButton : ToggleButton
{
public bool InvertCheckStateOrder
{
get { return (bool)GetValue(InvertCheckStateOrderProperty); }
set { SetValue(InvertCheckStateOrderProperty, value); }
}
// Using a DependencyProperty as the backing store for InvertCheckStateOrder. This enables animation, styling, binding, etc...
public static readonly DependencyProperty InvertCheckStateOrderProperty = DependencyProperty.Register("InvertCheckStateOrder", typeof(bool), typeof(ToggleButtonInvertido), new UIPropertyMetadata(false));
protected override void OnToggle()
{
if (this.InvertCheckStateOrder)
{
if (this.IsChecked == true)
{
this.IsChecked = false;
}
else if (this.IsChecked == false)
{
this.IsChecked = this.IsThreeState ? null : (bool?)true;
}
else
{
this.IsChecked = true;
}
}
else
{
if (!this.IsChecked.HasValue)
this.IsChecked = true;
else
base.OnToggle();
}
}
}