示例#1
0
 protected virtual void OnCanExecuteChanged(IModel model)
 {
     foreach (EventCommandRef commandRef in EventCommands.GetCommandRefs(model, this))
     {
         WeakEvents.Call(_canExecuteChanged, h => h(commandRef, EventArgs.Empty));
     }
 }
示例#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);
        }
示例#3
0
 protected void Subscribe(EventCommand command, Action execute, Func <bool> canExecute = null)
 {
     EventCommands.Subscribe(this, command, execute, canExecute);
 }
示例#4
0
 protected void Unsubscribe()
 {
     EventCommands.Unsubscribe(this);
 }
示例#5
0
 protected void Unsubscribe(EventCommand command)
 {
     EventCommands.Unsubscribe(this, command);
 }