public ParameterizedCommandWithCanExecuteConditionUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #parameterizedCommandWithCanExecuteCondition
            Func <int, bool> canExecute = (p) => (2 + 2 == p);
            // This command is created as parameterized and with `canExecute` parameter.
            DelegateCommand <int> command = new DelegateCommand <int>((v) =>
            {
                XtraMessageBox.Show(string.Format(
                                        "Hello! The parameter passed to command is {0}." + Environment.NewLine +
                                        "And I'm running, because the `canExecute` condition is `True` for this parameter." + Environment.NewLine +
                                        "Try to change this parameter!", v));
            }, canExecute);
            //
            int parameter = 4;
            // UI binding for button with `queryParameter` function
            commandButton.BindCommand(command, () => parameter);
            #endregion #parameterizedCommandWithCanExecuteCondition
        }
Example #2
0
        public SimpleCommandUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #simpleCommand
            // This is simple legacy-command. It provide the Execute method for doing something.
            LegacyCommand command = new LegacyCommand();
            // UI binding for button
            commandButton.BindCommand(command);
            #endregion #simpleCommand
        }
        public ParameterizedCommandUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #parameterizedCommand
            // This is legacy-command with both the Execute(object) and the CanExecute(object) methods.
            LegacyCommandWithParameter command = new LegacyCommandWithParameter();
            int parameter = 4;
            // UI binding for button with `queryParameter` function
            commandButton.BindCommand(command, () => parameter);
            #endregion #parameterizedCommand
        }
        public SimpleCommandUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #simpleCommand
            // This is simple command. It just for doing something.
            DelegateCommand command = new DelegateCommand(() =>
            {
                XtraMessageBox.Show("Hello! I'm running!");
            });
            // UI binding for button
            commandButton.BindCommand(command);
            #endregion #simpleCommand
        }
        public CommandWithCanExecuteConditionUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #commandWithCanExecuteCondition
            Func <bool> canExecute = () => (2 + 2 == 4);
            // This command is created with `canExecute` parameter.
            DelegateCommand command = new DelegateCommand(() =>
            {
                XtraMessageBox.Show("Hello! I'm running, because the `canExecute` condition is `True`. Try to change this condition!");
            }, canExecute);
            // UI binding for button
            commandButton.BindCommand(command);
            #endregion #commandWithCanExecuteCondition
        }
        public ParameterizedCommandUserControl()
        {
            InitializeComponent();
            #region SetUp
            SimpleButton commandButton = new SimpleButton();
            commandButton.Text   = "Execute Command";
            commandButton.Dock   = DockStyle.Top;
            commandButton.Parent = this;
            #endregion SetUp

            #region #parameterizedCommand
            // This command is created as parameterized.
            DelegateCommand <object> command = new DelegateCommand <object>((v) =>
            {
                XtraMessageBox.Show(string.Format("Hello! The parameter passed to command is {0}. Try to change this parameter!", v));
            });
            //
            object parameter = 5;
            // UI binding for button with `queryParameter` function
            commandButton.BindCommand(command, () => parameter);
            #endregion #parameterizedCommand
        }