internal static IEnumerable <EventCommandRef> GetCommandRefs(IModel model, EventCommand command) { ModelHandlers handlers = GetModelHandlers(command, model, false); if (handlers == null) { return(Enumerable.Empty <EventCommandRef>()); } lock (handlers) { var result = new List <EventCommandRef>(); foreach (var wr in handlers.CommandRefs) { EventCommandRef commandRef; if (wr.TryGetTarget(out commandRef)) { result.Add(commandRef); } } return(result); } }
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); }
protected void Subscribe(EventCommand command, Action execute, Func <bool> canExecute = null) { EventCommands.Subscribe(this, command, execute, canExecute); }
protected void Unsubscribe(EventCommand command) { EventCommands.Unsubscribe(this, command); }