Controller Interaction (Part 5 of 6)
This part of the tutorial will show how to invoke code on the page controller from the UI.
Adding a second button to the Overview page
Just like the OpenPage button we added in a previous part of the tutorial, this is completely up to you on how you do this. If you completed the steps back then, you can go ahead and do the following to add the button:
- Open the XAML view of the Overview page, Overview.xaml.
- Wrap the Edit button in a StackPanel with Orientation set to
Horizontal, and add a second button:
<StackPanel HorizontalAlignment="Right" Height="30" Margin="0, 10, 0, 0"
Orientation="Horizontal">
<Button Width="75" Content="Edit"
Command="{vi:OpenPage CustomerEdit}"
CommandParameter="{Binding SelectedItem,ElementName=PART_2}" />
<Button Width="125" Content="Make phonecall"
Command="{vi:HandledByController MakePhonecall}"
CommandParameter="{Binding SelectedItem, ElementName=PART_2}" />
</StackPanel>
Note: Notice the HandledByController extension. This will invoke the MakePhonecall method on the Overview pagecontroller. Passing the selected customer as argument.
- Implement a MakePhonecall on the Overview pagecontroller by opening the Overview.cs file in the AdventureWorksDemo.Module project (under Customers\PageControllers):
- Optionally, you can set a breakpoint at the beginning of this method to verify that the code is called.
public void MakePhonecall(Customer entity)
{
// PhoneHelper.StartCall(entity.Phone);
}
Launching the application
- Run the application by pressing CTRL+F5 or the Play button on the toolbar.
- In the application, click the Customers module.
- Select a customer from the list and click Make phonecall at the bottom. This will invoke the code in the MakePhonecall method.

