public static void OnSetCommandCallback(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { var toggleBtn = depObj as CheckBox; if (toggleBtn != null) { CheckBoxCommandBehavior behavior = GetOrCreateBehavior(toggleBtn); behavior.Command = e.NewValue as ICommand; } }
private static void OnSetCommandParameterCallback(DependencyObject depObject, DependencyPropertyChangedEventArgs e) { var toggleBtn = depObject as CheckBox; if (toggleBtn != null) { CheckBoxCommandBehavior behavior = GetOrCreateBehavior(toggleBtn); behavior.CommandParameter = e.NewValue; } }
public static CheckBoxCommandBehavior GetOrCreateBehavior(CheckBox toggleBtn) { var behavior = toggleBtn.GetValue(CheckBoxCommandBehaviorProperty) as CheckBoxCommandBehavior; if (behavior == null) { behavior = new CheckBoxCommandBehavior(toggleBtn); toggleBtn.SetValue(CheckBoxCommandBehaviorProperty, behavior); } return(behavior); }