IsChecked will have a valid value during command execution.
ToggleButton overrides OnClick from ButtonBase as follows:
protected override void OnClick() { OnToggle(); base.OnClick(); }
OnToggle is a method that updates IsChecked :
protected internal virtual void OnToggle() { // If IsChecked == true && IsThreeState == true ---> IsChecked = null // If IsChecked == true && IsThreeState == false ---> IsChecked = false // If IsChecked == false ---> IsChecked = true // If IsChecked == null ---> IsChecked = false bool? isChecked; if (IsChecked == true) isChecked = IsThreeState ? (bool?)null : (bool?)false; else // false or null isChecked = IsChecked.HasValue; // HasValue returns true if IsChecked==false SetCurrentValueInternal(IsCheckedProperty, isChecked); }
And the OnClick base runs the command:
protected virtual void OnClick() { RoutedEventArgs newEvent = new RoutedEventArgs(ButtonBase.ClickEvent, this); RaiseEvent(newEvent); MS.Internal.Commands.CommandHelpers.ExecuteCommandSource(this); }
Source: MSDN Reference Source
Thus, the value must be valid at the time the command is run.
source share