public void Bind(ICommandWrapper cmd, ToolStripItem clickable) { var bi = new CommandToControlBindingItem(cmd, clickable); this.bindings.Add(bi); clickable.Enabled = cmd.CanExecute(null); cmd.CanExecuteChanged += (object sender, EventArgs e) => { clickable.Enabled = cmd.CanExecute(null); }; clickable.Click += (object sender, EventArgs e) => { if (cmd.CanExecute(null)) { cmd.Execute(null); } }; }
public void Bind(ICommandWrapper cmd, Control clickable) { var bi = new CommandToClickCommandEnabledUpdater(cmd, clickable); this.bindings.Add(bi); // TODO implemen can execute changed in the same manner clickable.Click += async(object sender, EventArgs e) => { if (cmd.CanExecute(null)) { await cmd.Execute(null); } }; }