private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RibbonTextBox textBox = (RibbonTextBox)d; ICommand oldCommand = (ICommand)e.OldValue; ICommand newCommand = (ICommand)e.NewValue; if (oldCommand != null) { textBox.UnhookCommand(oldCommand); } if (newCommand != null) { textBox.HookCommand(newCommand); } RibbonHelper.OnCommandChanged(d, e); }