/// <summary>
 /// Sets the Behavior property.  
 /// </summary>
 private static void SetBehavior(DependencyObject d, CommandBehaviorBinding value)
 {
     d.SetValue(BehaviorProperty, value);
 }
 //tries to get a CommandBehaviorBinding from the element. Creates a new instance if there is not one attached
 private static CommandBehaviorBinding FetchOrCreateBinding(DependencyObject d)
 {
     CommandBehaviorBinding binding = GetBehavior(d);
     if (binding == null)
     {
         binding = new CommandBehaviorBinding();
         SetBehavior(d, binding);
     }
     return binding;
 }
        /// <summary>
        /// Handles changes to the CommandParameter property.
        /// </summary>
        private static void OnCommandParameterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CommandBehaviorBinding binding = FetchOrCreateBinding(d);

            binding.CommandParameter = e.NewValue;
        }
 /// <summary>
 /// Sets the Behavior property.
 /// </summary>
 private static void SetBehavior(DependencyObject d, CommandBehaviorBinding value)
 {
     d.SetValue(BehaviorProperty, value);
 }
        /// <summary>
        /// Handles changes to the Action property.
        /// </summary>
        private static void OnActionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CommandBehaviorBinding binding = FetchOrCreateBinding(d);

            binding.Action = (Action <object>)e.NewValue;
        }