public ConfirmationBehaviorGenericConfirmationBehaviorClassUserControl() { 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 #confirmationBehaviorGenericConfirmationBehaviorClass // UI binding for the generic ConfirmationBehavior behavior with some specific parameters mvvmContext.AttachBehavior <ConfirmationBehavior <ChangingEventArgs> >(editor, behavior => { behavior.Caption = "CheckEdit State changing"; behavior.Text = "This checkEdit's checked-state is about to be changed. Are you sure?"; behavior.Buttons = ConfirmationButtons.YesNo; behavior.ShowQuestionIcon = true; }, "EditValueChanging"); #endregion #confirmationBehaviorGenericConfirmationBehaviorClass }
public ConfirmationBehaviorSeparateClassUserControl() { 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 #confirmationBehaviorSeparateClass // UI binding for the EditValueChangingConfirmation behavior mvvmContext.AttachBehavior <EditValueChangingConfirmation>(editor); #endregion #confirmationBehaviorSeparateClass }
public UsingCommandsWithThirdPartyControlsUserControl() { 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 #usingCommandsWithThirdPartyControls mvvmContext.ViewModelType = typeof(ViewModel); // UI binding for the ClickToSayHello behavior mvvmContext.AttachBehavior <ClickToSayHello>(thirdPartyButton); #endregion #usingCommandsWithThirdPartyControls }