Example #1
0
        public void T718930()
        {
            var bt = new Button();
            var cb = new System.Windows.Input.CommandBinding()
            {
                Command = System.Windows.Input.ApplicationCommands.Open
            };
            int exCount  = 0;
            int canCount = 0;

            cb.Executed   += (d, e) => { exCount++; };
            cb.CanExecute += (d, e) => { canCount++; e.CanExecute = true; };
            bt.CommandBindings.Add(cb);

            var bt1 = new Button();
            var etc = new EventToCommand()
            {
                EventName     = "Loaded",
                Command       = System.Windows.Input.ApplicationCommands.Open,
                CommandTarget = bt
            };

            Interaction.GetBehaviors(bt1).Add(etc);

            var root = new StackPanel();

            root.Children.Add(bt);
            root.Children.Add(bt1);
            Window.Content = root;
            Window.Show();
            DispatcherHelper.DoEvents();
            Assert.AreEqual(1, exCount);
            Assert.AreEqual(2, canCount);
        }
Example #2
0
 public System.Windows.Input.CommandBinding AddZoomOut(
     System.Windows.Input.CommandBindingCollection commandBindings)
 {
     if (commandBindings != null)
     {
         var cb =
             new System.Windows.Input.CommandBinding(
                 ZoomOutCommand,
                 ZoomOutExecuted,
                 CanExecuteZoomOut);
         commandBindings.Add(cb);
         return(cb);
     }
     else
     {
         return(null);
     }
 }
Example #3
0
 public System.Windows.Input.CommandBinding AddShrinkRoi(
     System.Windows.Input.CommandBindingCollection commandBindings)
 {
     if (commandBindings != null)
     {
         var cb =
             new System.Windows.Input.CommandBinding(
                 ShrinkRoiCommand,
                 ShrinkRoiExecuted,
                 CanExecuteShrinkRoi);
         commandBindings.Add(cb);
         return(cb);
     }
     else
     {
         return(null);
     }
 }