Exemple #1
0
        public UsingCommandsWithThirdPartyControlsFluentAPIUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            Button thirdPartyButton = new Button();
            thirdPartyButton.Dock   = DockStyle.Top;
            thirdPartyButton.Text   = "Execute Command";
            thirdPartyButton.Parent = this;

            #endregion SetUp

            #region #usingCommandsWithThirdPartyControlsFluentAPI
            mvvmContext.ViewModelType = typeof(ViewModel);
            // UI binding for the EventToCommand behavior (using FluentAPI)
            mvvmContext.WithEvent <ViewModel, EventArgs>(thirdPartyButton, "Click")
            .EventToCommand(x => x.SayHello());
            #endregion #usingCommandsWithThirdPartyControlsFluentAPI
        }
        public ConfirmationBehaviorFluentAPIUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            CheckEdit editor = new CheckEdit();
            editor.Dock   = DockStyle.Top;
            editor.Text   = "Please, try to change checked state of this editor";
            editor.Parent = this;

            #endregion SetUp

            #region #confirmationBehaviorFluentAPI
            // UI binding for the generic ConfirmationBehavior behavior with some specific parameters
            mvvmContext.WithEvent <ChangingEventArgs>(editor, "EditValueChanging")
            .Confirmation(behavior =>
            {
                behavior.Caption = "CheckEdit State changing";
                behavior.Text    = "This checkEdit's checked-state is about to be changed. Are you sure?";
            });
            #endregion #confirmationBehaviorFluentAPI
        }