Ejemplo n.º 1
0
        // 依存プロパティが変更されたときの処理
        private static void OnMustToggleIsEnabledChanged(
            DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            EventToCommand parent = obj as EventToCommand;

            if (parent != null && e.NewValue != null)
            {
                if (parent.AssociatedObject == null)
                {
                    return;
                }

                parent.EnableDisableElement();
            }
        }
Ejemplo n.º 2
0
        private static void OnCommandChanged(
            EventToCommand element,
            DependencyPropertyChangedEventArgs e)
        {
            if (element == null)
            {
                return;
            }

            if (e.OldValue != null)
            {
                ((ICommand)e.OldValue).CanExecuteChanged -= element.OnCommandCanExecuteChanged;
            }

            var command = (ICommand)e.NewValue;

            if (command != null)
            {
                command.CanExecuteChanged += element.OnCommandCanExecuteChanged;
            }

            element.EnableDisableElement();
        }