// Set the header to the command text if no header has been explicitly specified

        /*private static object CoerceContent(DependencyObject d, object value) {
         *      CommandButton button = (CommandButton) d;
         *      RelayUICommand uiCommand;
         *
         *      // If no header has been set, use the command's text
         *      if (button.IsValueUnsetAndNull(ContentProperty) && button.Command is RelayUICommand uiCommand) {
         *              value = uiCommand.Text;
         *      }
         *
         *      return value;
         * }*/


        // Set the icon to the command text if no icon has been explicitly specified
        private static object CoerceSource(DependencyObject d, object value)
        {
            CommandButton button = (CommandButton)d;

            // If no icon has been set, use the command's icon
            if (button.IsValueUnsetAndNull(SourceProperty, value) && button.Command is IRelayUICommand uiCommand)
            {
                value = uiCommand.Icon;
            }
            return(value);
        }
        private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CommandButton button = (CommandButton)d;

            if (e.OldValue is RelayUICommand oldUICommand)
            {
                oldUICommand.PropertyChanged -= button.OnCommandPropertyChanged;
            }
            if (e.NewValue is RelayUICommand newUICommand)
            {
                newUICommand.PropertyChanged += button.OnCommandPropertyChanged;
            }

            d.CoerceValue(SourceProperty);
            //d.CoerceValue(ContentProperty);
            d.CoerceValue(ToolTipProperty);
        }
        // Gets the input gesture text from the command text if it hasn't been explicitly specified
        private static object CoerceToolTip(DependencyObject d, object value)
        {
            CommandButton button = (CommandButton)d;

            if (button.IsValueUnsetAndNull(ToolTipProperty, value) && button.Command is IRelayUICommand uiCommand)
            {
                string tooltip = "";
                if (!string.IsNullOrEmpty(uiCommand.Text))
                {
                    tooltip += uiCommand.Text;
                }
                if (uiCommand.InputGesture != null)
                {
                    if (!string.IsNullOrEmpty(tooltip))
                    {
                        tooltip += " ";
                    }
                    tooltip += $"({uiCommand.InputGesture.GetDisplayStringForCulture(CultureInfo.CurrentCulture)})";
                }
                return(tooltip);
            }

            return(value);
        }