How to: Add a Custom Command to a Silverlight Screen
For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.
You can add custom code that runs when the user clicks a button on a screen. First, add a custom command to a screen. Then, add custom code that runs when the user clicks the button.
In the Screen Content Tree of the Screen Designer, decide where you want to place the command, and then perform one of the following actions:
Right-click the desired node, and then select Add Button.
Select the desired node. Then, on the command bar of the Screen Designer, click Add Layout Item, and then click Button.
The Add Button dialog box appears.
In the Add Button dialog box, select one of the following options:
Select New Method if you want to create a method that runs when the user clicks the button.
Select Existing Method if you want to use a method that has already been added to the screen. You must select the method from the Name drop-down list.
In the Screen Content Tree, right-click the command, and then click Edit Execute Code.
The Code Editor opens and generates a method named ButtonName_Execute.
Add custom code to the ButtonName_Execute method.