示例#1
0
 static void UpdateObservedIsPresent(ButtonBase b)
 {
     if (b != null)
     {
         b.SetCurrentValue(IsPressedProperty, b.IsPressed);
     }
 }
示例#2
0
        static void Command_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ButtonBase buttonBase = (ButtonBase)d;

            if (e.OldValue != null && e.NewValue == null)
            {
                buttonBase.Click -= ExecuteCommand;
            }
            if (e.OldValue == null && e.NewValue != null)
            {
                buttonBase.Click += ExecuteCommand;
            }

            // Set IsEnabled value depending on CanExecute
            if (buttonBase.Command != null)
            {
                buttonBase.SetCurrentValue(IsEnabledProperty, buttonBase.IsEnabled && buttonBase.Command.CanExecute(buttonBase.CommandParameter));
            }
        }