internal static ICommandBinding CreatePropertyBinding(object source, string sourcePropertyName, string targetPropertyName, Func <object, object> format, object[] targets, bool syncTargets)
        {
            if (source == null)
            {
                Throw.ArgumentNullException(Argument.source);
            }
            if (sourcePropertyName == null)
            {
                Throw.ArgumentNullException(Argument.sourcePropertyName);
            }
            if (targetPropertyName == null)
            {
                Throw.ArgumentNullException(Argument.targetPropertyName);
            }

            var state = new CommandState
            {
                { stateSourcePropertyName, sourcePropertyName },
                { stateTargetPropertyName, targetPropertyName },
                { stateFormatValue, format }
            };
            bool            isNotifyPropertyChanged = source is INotifyPropertyChanged;
            string          eventName = isNotifyPropertyChanged ? nameof(INotifyPropertyChanged.PropertyChanged) : sourcePropertyName + "Changed";
            ICommandBinding result    = UpdatePropertyCommand.CreateBinding(state)
                                        .AddStateUpdater(NullStateUpdater.Updater)
                                        .AddSource(source, eventName);

            if (!targets.IsNullOrEmpty())
            {
                foreach (object target in targets)
                {
                    result.AddTarget(target);
                }

                if (syncTargets)
                {
                    result.InvokeCommand(source, eventName, isNotifyPropertyChanged ? new PropertyChangedEventArgs(sourcePropertyName) : EventArgs.Empty);
                }
            }

            return(result);
        }
        public static ICommandBinding CreateBinding(this ICommand command, object source, string eventName, IDictionary <string, object> initialState = null, params object[] targets)
        {
            if (source == null)
            {
                Throw.ArgumentNullException(Argument.source);
            }
            if (eventName == null)
            {
                Throw.ArgumentNullException(Argument.eventName);
            }
            ICommandBinding result = command.CreateBinding(initialState).AddSource(source, eventName);

            if (!targets.IsNullOrEmpty())
            {
                foreach (object target in targets)
                {
                    result.AddTarget(target);
                }
            }

            return(result);
        }