private static void OnRichCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var button = d as RepeatButtonRichCommand;

            if (button == null)
            {
                return;
            }
            var command = e.NewValue as RichDelegateCommand;

            if (command == null)
            {
                return;
            }

            ButtonRichCommand.ConfigureButtonFromCommand(button, command, button.ShowTextLabel);
        }
        private void OnCommandDataChanged(object sender, EventArgs e)
        {
            var command = sender as RichDelegateCommand;

            if (command == null)
            {
                return;
            }

            if (command != Command)
            {
#if DEBUG
                Debugger.Break();
#endif
                return;
            }

            ButtonRichCommand.RefreshButtonFromItsRichCommand(this, ShowTextLabel);
        }
 public void SetRichCommand(RichDelegateCommand command)
 {
     ButtonRichCommand.SetRichCommand(command, this, ShowTextLabel, OnCommandDataChanged);
 }
        public static void OnRichCommandActiveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var button = d as TwoStateButtonRichCommand;

            if (button == null)
            {
                return;
            }
            var choice = (Boolean)e.NewValue;

            //RichDelegateCommand command = button.RichCommandOne;

            //if (command.KeyGesture == null && button.RichCommandTwo.KeyGesture != null)
            //{
            //    command.KeyGestureText = button.RichCommandTwo.KeyGestureText;
            //}


            if (button.InputBindingManager != null)
            {
                if (choice)
                {
                    if (true
                        //&& KeyGestureString.AreEqual(command.KeyGesture, button.RichCommandTwo.KeyGesture)
                        //&& command.KeyGesture.Equals(button.RichCommandTwo.KeyGesture)
                        )
                    {
                        if (button.RichCommandTwo.KeyGesture != null)
                        {
                            button.InputBindingManager.RemoveInputBinding(button.RichCommandTwo.KeyBinding);
                        }

                        if (button.RichCommandOne.KeyGesture != null)
                        {
                            button.InputBindingManager.AddInputBinding(button.RichCommandOne.KeyBinding);
                        }
                    }
                }
                else
                {
                    //command = button.RichCommandTwo;

                    //if (command.KeyGesture == null && button.RichCommandOne.KeyGesture != null)
                    //{
                    //    command.KeyGestureText = button.RichCommandOne.KeyGestureText;
                    //}

                    if (true
                        //&& KeyGestureString.AreEqual(command.KeyGesture, button.RichCommandOne.KeyGesture)
                        //&& command.KeyGesture.Equals(button.RichCommandOne.KeyGesture)
                        )
                    {
                        if (button.RichCommandOne.KeyGesture != null)
                        {
                            button.InputBindingManager.RemoveInputBinding(button.RichCommandOne.KeyBinding);
                        }

                        if (button.RichCommandTwo.KeyGesture != null)
                        {
                            button.InputBindingManager.AddInputBinding(button.RichCommandTwo.KeyBinding);
                        }
                    }
                }
            }

            ButtonRichCommand.ConfigureButtonFromCommand(button,
                                                         choice ? button.RichCommandOne : button.RichCommandTwo,
                                                         button.ShowTextLabel);
        }