Programmatic Method Execution

A method can be executed programmatically using code-behind in conjunction with or instead of being triggered by events specified by the EventTriggers property.

Additonally, the ExecutedSuccessfully and ExecutedWithError events can be handled programmatically. For more information, see Server and Client Method Events.

All bindings to return values, as well as inputs, function the same whether the method is executed programmatically or as the result of a configured EventTrigger. To execute a method programmatically, use the following in the code-behind editor.

ExecuteMethod (string methodName)

For detailed steps, see Execute a WPF Method Programmatically.

Full example in VB for WPF

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Windows
Imports System.Windows.Controls
Imports Proficy.Platform.Core.DisplayFramework.Forms

Partial Public Class MainForm
       Inherits FormBase

       Public Sub New()
              InitializeComponent()
       
              AddHandler Button1.Click, AddressOf Me.Button1_Click

       End Sub
                     
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
       Me.ExecuteMethod("SampleMethod")
End Sub

End Class

Full example in C# for WPF

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using Proficy.Platform.Core.DisplayFramework.Forms;

namespace Dev
{
    public partial class MainForm : FormBase
    {
        public MainForm()
        {
            InitializeComponent();
     
            Button1.Click += new System.Windows.RoutedEventHandler(this.Button1_Click);
        }

private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) {
       this.ExecuteMethod("SampleMethod");
}

    }
}

Full example in C# for Silverlight

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using Proficy.Platform.Core.DisplayFramework.Forms;

namespace Dev
{
    public partial class MainForm : FormBase
    {
        public MainForm()
        {
            InitializeComponent();
     
            Button1.Click += new System.Windows.RoutedEventHandler(this.Button1_Click);
        }

private void Button1_Click(object sender, System.Windows.RoutedEventArgs e) {
       this.SampleMethod.Execute();
}

    }
}