Ejemplo n.º 1
0
        public RibbonDialogServiceUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            SimpleButton commandButton = new SimpleButton();
            commandButton.Text = "Execute Command";
            commandButton.Dock = DockStyle.Top;

            MemoEdit memo = new MemoEdit();
            memo.Dock = DockStyle.Top;
            memo.Properties.ReadOnly = true;
            memo.MinimumSize         = new System.Drawing.Size(0, 100);

            commandButton.Parent = this;
            memo.Parent          = this;

            #endregion SetUp

            #region #ribbonDialogService
            // Force use the RibbonDialogService
            MVVMContext.RegisterRibbonDialogService();
            //
            mvvmContext.ViewModelType = typeof(NotesViewModel);
            // UI binding for Notes
            mvvmContext.SetBinding(memo, m => m.EditValue, "Notes");
            // UI binding for button
            mvvmContext.BindCommand <NotesViewModel>(commandButton, x => x.EditNotes());
            #endregion #ribbonDialogService
        }
        public SimpleCommandWithCancellationUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            ProgressBarControl progressBar = new ProgressBarControl();
            progressBar.Dock = DockStyle.Top;

            SimpleButton commandButton = new SimpleButton();
            commandButton.Text = "Start Command Execution";
            commandButton.Dock = DockStyle.Top;

            SimpleButton cancelButton = new SimpleButton();
            cancelButton.Text = "Cancel Command Execution";
            cancelButton.Dock = DockStyle.Top;

            cancelButton.Parent  = this;
            commandButton.Parent = this;
            progressBar.Parent   = this;
            #endregion SetUp

            #region #simpleCommandWithCancellation
            mvvmContext.ViewModelType = typeof(ViewModelWithAsyncCommandAndCancellation);
            // UI binding for button
            mvvmContext.BindCommand <ViewModelWithAsyncCommandAndCancellation>(commandButton, x => x.DoSomethingAsynchronously());
            // UI binding for cancelation
            mvvmContext.BindCancelCommand <ViewModelWithAsyncCommandAndCancellation>(cancelButton, x => x.DoSomethingAsynchronously());
            // UI binding for progress
            mvvmContext.SetBinding(progressBar, p => p.EditValue, "Progress");
            #endregion #simpleCommandWithCancellation
        }
Ejemplo n.º 3
0
        public DataBindingViaMVVMContextUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            TextEdit editor = new TextEdit();
            editor.Dock = DockStyle.Top;
            editor.Properties.NullValuePrompt = "Please, enter the Title here...";
            editor.Properties.NullValuePromptShowForEmptyValue = true;

            SimpleButton commandButton = new SimpleButton();
            commandButton.Dock = DockStyle.Top;
            commandButton.Text = "Report the Title property value";

            commandButton.Parent = this;
            editor.Parent        = this;
            #endregion SetUp

            #region #dataBindingViaMVVMContext
            var legacyViewModel = new LegacyViewModel("Legacy ViewModel");
            // initialize the MVVMContext with the specific ViewModel's instance
            mvvmContext.SetViewModel(typeof(LegacyViewModel), legacyViewModel);
            // Data binding for the Title property (via MVVMContext API)
            mvvmContext.SetBinding(editor, e => e.EditValue, "Title");
            // UI binding for the Report command
            commandButton.Click += (s, e) => XtraMessageBox.Show(legacyViewModel.Title);
            #endregion #dataBindingViaMVVMContext
        }
Ejemplo n.º 4
0
        public DataBindingToNestedPropertiesUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            TextEdit editor = new TextEdit();
            editor.Dock = DockStyle.Top;
            editor.Properties.NullValuePrompt = "Please, enter the Title here...";
            editor.Properties.NullValuePromptShowForEmptyValue = true;

            SimpleButton commandButton = new SimpleButton();
            commandButton.Dock = DockStyle.Top;
            commandButton.Text = "Report the Title property value";

            commandButton.Parent = this;
            editor.Parent        = this;
            #endregion SetUp

            #region #dataBindingToNestedProperties
            // Set type of POCO-ViewModel
            mvvmContext.ViewModelType = typeof(ViewModel);
            // Data binding for the Title property of nested ViewModel  (via MVVMContext API)
            mvvmContext.SetBinding(editor, e => e.EditValue, "Child.Title");
            // UI binding for the Report command
            ViewModel viewModel = mvvmContext.GetViewModel <ViewModel>();
            commandButton.Click += (s, e) => XtraMessageBox.Show(viewModel.GetChildTitleAsHumanReadableString());
            #endregion #dataBindingToNestedProperties
        }
        public SimpleUITriggerUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            CheckEdit checkEdit = new CheckEdit();
            checkEdit.Dock = DockStyle.Top;
            checkEdit.Text = "IsActive";

            LabelControl label = new LabelControl();
            label.Dock         = DockStyle.Top;
            label.AutoSizeMode = LabelAutoSizeMode.Vertical;
            label.Text         = "Inactive";

            label.Parent     = this;
            checkEdit.Parent = this;
            #endregion SetUp

            #region #simpleUITrigger
            // Set type of POCO-ViewModel
            mvvmContext.ViewModelType = typeof(UIViewModel);
            // Data binding for the IsActive property
            mvvmContext.SetBinding <CheckEdit, UIViewModel, bool>(checkEdit, c => c.Checked, x => x.IsActive);
            // Property-change Trigger for the IsActive property
            mvvmContext.SetTrigger <UIViewModel, bool>(x => x.IsActive, (active) =>
            {
                label.Text = active ? "Active" : "Inactive";
            });
            #endregion #simpleUITrigger
        }
Ejemplo n.º 6
0
        public PropertyChangedNotificationsUserControl()
        {
            InitializeComponent();
            #region SetUp
            MVVMContext mvvmContext = new MVVMContext();
            mvvmContext.ContainerControl = this;

            TextEdit editor1 = new TextEdit();
            editor1.Dock = DockStyle.Top;
            editor1.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            editor1.Properties.Mask.EditMask = "n0";
            editor1.Properties.Mask.UseMaskAsDisplayFormat = true;

            TextEdit editor2 = new TextEdit();
            editor2.Dock = DockStyle.Top;
            editor2.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            editor2.Properties.Mask.EditMask = "n0";
            editor2.Properties.Mask.UseMaskAsDisplayFormat = true;

            LabelControl resultLabel = new LabelControl();
            resultLabel.Dock         = DockStyle.Top;
            resultLabel.AutoSizeMode = LabelAutoSizeMode.Vertical;

            resultLabel.Parent = this;
            editor1.Parent     = this;
            editor2.Parent     = this;
            #endregion SetUp

            #region #propertyChangedNotifications
            // Set type of POCO-ViewModel
            mvvmContext.ViewModelType = typeof(SumViewModel);
            // Data binding for the operands
            mvvmContext.SetBinding(editor1, e => e.EditValue, "Operand1");
            mvvmContext.SetBinding(editor2, e => e.EditValue, "Operand2");
            // Data binding for the result
            mvvmContext.SetBinding(resultLabel, l => l.Text, "ResultText");
            #endregion #propertyChangedNotifications
        }
Ejemplo n.º 7
0
            public NotesEditor()
            {
                this.Padding     = new Padding(12);
                this.MinimumSize = new System.Drawing.Size(320, 160);
                //
                MVVMContext mvvmContext = new MVVMContext();

                mvvmContext.ContainerControl = this;
                mvvmContext.ViewModelType    = typeof(EditNotesViewModel);
                //
                MemoEdit memo = new MemoEdit();

                memo.Dock   = DockStyle.Fill;
                memo.Parent = this;
                // Data-binding for Notes
                mvvmContext.SetBinding(memo, m => m.EditValue, "Notes");
            }