Exemple #1
0
        private static void BindInternal(string?oldValue, string?newValue, IBinderControllable binder, DependencyObject affectedPart)
        {
            _isIn = true;

            if (oldValue != null)
            {
                binder.CleanUp(NamePrefix + oldValue);
            }
            if (newValue == null)
            {
                return;
            }

            var name = NamePrefix + newValue;

            if (newValue != null && newValue.Contains(':'))
            {
                var vals = newValue.Split(new[] { ':' }, 2);
                newValue = vals[1];

                var command = Find(vals[0]);
                if (command != null)
                {
                    SetTargetCommand(affectedPart, command);
                }
            }
            else if (GetTargetCommand(affectedPart) == null && newValue != null)
            {
                var command = Find(newValue);
                if (command != null)
                {
                    SetTargetCommand(affectedPart, command);
                }
            }
            else
            {
                var command = GetTargetCommand(affectedPart);
                if (command is RoutedCommand routedCommand)
                {
                    name = NamePrefix + routedCommand.Name;
                }
                else
                {
                    name = NamePrefix + command;
                }
            }

            var newlinker = new CommandLinker {
                CommandTarget = newValue
            };

            binder.Register(name, newlinker, affectedPart);
            _isIn = false;
        }
Exemple #2
0
        private static void BindInternal(string?oldValue, string?newValue, IBinderControllable binder, DependencyObject affectedPart)
        {
            if (oldValue != null)
            {
                binder.CleanUp(EventBinderPrefix + oldValue);
            }

            if (newValue == null)
            {
                return;
            }

            binder.Register(EventBinderPrefix + newValue, new EventLinker {
                Commands = newValue
            }, affectedPart);
        }
        private static void SetLinker(string?newName, string?oldName, IBinderControllable root, IUIObject obj,
                                      Func <LinkerBase> factory)
        {
            if (oldName != null)
            {
                root.CleanUp(ControlHelperPrefix + oldName);
            }

            if (newName == null)
            {
                return;
            }

            var linker = factory();

            linker.Name = newName;
            root.Register(ControlHelperPrefix + newName, linker, obj);
        }