Ejemplo n.º 1
0
        internal static void AddCommandRef(IModel model, EventCommand command, EventCommandRef commandRef)
        {
            ModelHandlers handlers = GetModelHandlers(command, model, true);

            lock (handlers) {
                handlers.CommandRefs.Add(new WeakReference <EventCommandRef>(commandRef));
                handlers.CommandRefs.RemoveStaleReferences();
            }
        }
Ejemplo n.º 2
0
        public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || value == DependencyProperty.UnsetValue)
                return DependencyProperty.UnsetValue;

            var model = value as IModel;
            if (model == null)
                throw new ArgumentException("value must be IModel", "value");
            EventCommand command = Command ?? Display.Command;

            var commandRef = new EventCommandRef {
                Command = command,
                Display = Display,
                Model = model,
            };
            EventCommands.AddCommandRef(model, command, commandRef);
            return commandRef;
        }
Ejemplo n.º 3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || value == DependencyProperty.UnsetValue)
            {
                return(DependencyProperty.UnsetValue);
            }

            var model = value as IModel;

            if (model == null)
            {
                throw new ArgumentException("value must be IModel", "value");
            }
            EventCommand command = Command ?? Display.Command;

            var commandRef = new EventCommandRef {
                Command = command,
                Display = Display,
                Model   = model,
            };

            EventCommands.AddCommandRef(model, command, commandRef);
            return(commandRef);
        }