Configure custom submit, cancel, and/or enable behavior in Silverlight forms
Submitting or cancelling a form is determined during the design of the workflow containing the form.
Procedure
- From the Project tree, open the file, MainPage.xaml.cs.
-
In the Main Page constructor, register the handlers with
the button click events by using the code below:
public MainPage() { InitializeComponent(); _interfaceHelpers[typeof(IResourceParameters)] = new FragmentMetadataByAttributes(this); _interfaceHelpers[typeof(IFragmentInitialization)] = new FragmentInitialization(this); InitializeProficyData(); MySubmitButton.Click += OnSubmit; MyCancelButton.Click += OnCancel; }
-
In each handler, add any custom code that is required, followed by the code
necessary to submit or cancel and close the form.
public void OnSubmit(object sender, EventArgs args) { //Custom Code MessageBox.Show("Submitting"); //Code required to submit the form if (FormHost != null) { FormHost.SubmitCommand.Execute(); } } public void OnCancel(object sender, EventArgs args) { //Custom Code MessageBox.Show("Cancelling"); //Code required to cancel the form if (FormHost != null) { FormHost.CancelCommand.Execute(); } }
-
The Submit button can be enabled or disabled depending
on the interaction of the operator with the Tasks List. For example, by adding
the following call method and setting the value in the form code, the
Submit button becomes disabled after the operator
performs an action:
FormProperties.SetIsSubmitEnabled(this, false)
.You can use this value to ensure that a form is submitted only after valid data is entered to prevent premature form submission. - To add code-designed forms to a workflow, see Configure a Form activity.