Exemple #1
0
        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;
            }
        }
Exemple #2
0
        private static void OnSetCommandParameterCallback(DependencyObject depObject, DependencyPropertyChangedEventArgs e)
        {
            var toggleBtn = depObject as CheckBox;

            if (toggleBtn != null)
            {
                CheckBoxCommandBehavior behavior = GetOrCreateBehavior(toggleBtn);
                behavior.CommandParameter = e.NewValue;
            }
        }
Exemple #3
0
        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);
        }