Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Adding a Local Property

In this lesson, you will learn how to how to customize a screen by adding a local property.

In addition to using the Screen Designer to customize the controls on a screen, you can also add data items, for example, a local property that can display a calculated value.

To add a local property

  1. In Solution Explorer, double-click the OrdersByCustomers screen.

  2. On the ToolBar Ribbon, click the Add Data Item button.

  3. In the Add Data Item dialog box, select Local Property and then click OK.

    A new node named Property1 is added to the left pane of the Screen Designer.

    The Property1 node is selected
  4. Select the Property1 node and then in the Properties window, select the Name property and type NumberOfOrders.

    The name also changes in the left pane of the designer.

  5. Drag the NumberOfOrders node just below the Rows Layout | Details Column node in the center pane.

  6. Press F5 to run the application, and on the navigation menu, click Orders By Customers to display the screen and verify the changes.

    Notice that a Number of Orders field is now displayed at the top of the right column, and that no value is displayed.

  7. Click the Close button in the upper-right corner of the application window to close it.

To display a value for a local property

  1. In the left pane of the Screen Designer, select the Customers node.

  2. On the ToolBar Ribbon, in the Write Code list, click Customers_SelectionChanged.

    The Code Editor opens and displays the Customers_SelectionChanged method.

  3. In the Customers_SelectionChanged method, add the following code.

    
    NumberOfOrders = Orders.Count.ToString();
    

    When a customer is selected, this code calculates the number of orders for that customer. That value is then displayed in the Number of Orders field.

  4. Press F5 to run the application, and on the navigation menu, click Orders By Customers to display the screen and verify the changes.

    Notice that when you select a customer, the number of orders for that customer is displayed in the Number of Orders field.

  5. Click the Close button in the upper-right corner of the application window to close it.

This lesson showed how to create a local property to display a calculated value on a screen. In this case, you used the SelectionChanged method of the customers collection to return the Count of orders every time a customer is selected. You may have noticed that the code uses the ToString method to covert the Count to a String. This is required because the local property was defined as a String in the Add Data Item dialog box. If you had instead selected Integer as the type, the conversion would not be required.

In addition to using a local property to display a calculated value, you can also use a local property to collect an input value from the user. For example, you could create a local property that displays a list of cities when a user specifies a geographical region.

In the next lesson, you will learn how to change the layout and appearance of the running application.

Next lesson: Customizing the Running Application

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft