private static void OnCommandInvalidated(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            UIElement element = (UIElement)dependencyObject;

            element.CommandBindings.Clear();

            CommandModel commandModel = e.NewValue as CommandModel;

            if (commandModel != null)
            {
                element.CommandBindings.Add(new CommandBinding(commandModel.Command, commandModel.OnExecute, commandModel.OnQueryEnabled));
            }

            CommandManager.InvalidateRequerySuggested();
        }
 public static void SetCommand(DependencyObject sender, CommandModel command)
 {
     sender.SetValue(CommandProperty, command);
 }