Execute a WPF method programmatically

Procedure

  1. From the navigator, click Global Displays > Forms.
  2. Add a form, or from the Forms list, select an existing form.
  3. Click Display Editor > Designer.
  4. Click the Method tab.
  5. Add a new method select it, and then click the Properties tab.
  6. In the Name field, enter SampleMethod.
  7. Click the Parameters tab, and then configue inputs, as required.
  8. Click the MainForm.xaml tab.
  9. Click the Toolbox tab.
  10. Expand the Buttons control group, and then select a button.
  11. Click and drag the control to the desired position in the Designer.
    Note: To apply the properties of a control to another control, click and drag the control to another control in the document tree. The Applying <control (control name)> to Target dialog box appears where you can select the option you want to use to apply to the control.
  12. Right-click the button control and select Add Event Handler.
    The Event Triggers dialog box appears.
  13. Expand the button control, select Click, and then click OK.
    The code-behind editor opens.
  14. Add the call to ExecuteMethod("SampleMethod").
  15. Click Save.