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.

Walkthrough: Designing a Screen

This walkthrough shows you how to use the LightSwitch screen designer to create a screen that displays customer data from the Northwind sample database. The screen designer is a visual design canvas that you can use to modify the appearance of a screen.

This walkthrough shows you how to perform the following tasks:

  • Create a screen

  • Change the layout of a screen

  • Remove fields from a screen

  • Change the order of items

  • Change the display name of an item

  • Change the control type of an item

  • Customize a screen in a running application

This walkthrough assumes that the Northwind sample database is installed on your computer and that you have added it as a data source in your project.

This section shows you how to create a screen to display the customer data from the Northwind sample database. This screen is divided into two parts. The first part displays a summary list of all the customers; the other part displays details about the customer that is selected. .

To create a screen

  1. In Solution Explorer, select Screens.

  2. On the Project menu, click Add Screen.

    The Add New Screen dialog box appears.

  3. In the Add New Screen dialog box, under Select a screen template, select List and Details Screen.

  4. Under Screen Name, type Customers.

  5. In the drop-down list under Screen Data, select <DataSourceName>.Customers.

  6. Under Additional Data to Include, select Customer Details and Customer Orders.

    This adds the fields of the Customer entity to the details part of the screen, together with a list of the orders that were placed by that customer.

    The following illustration shows how the dialog box appears after you have performed the steps in this section.

    Add new screen dialog box
  7. Click OK to create the screen.

    The Screen Designer appears.

The List and Details screen has two columns. The left column is a list of the customers. The right column contains two rows. The top row contains the details of the selected customer and the bottom row contains orders that are related to the selected customer. The screen content tree of the screen designer shows how this list is composed.

This section shows how to modify the layout of the screen so that the screen contains two rows instead of two columns. The top row will contain the list of customers. The bottom row will contain two columns. The left column will contain the details of the selected customer and the right column will contain the orders that are related to the selected customer.

To change the layout of the list

  1. In the Screen Content Tree of the Screen Designer, change the layout of the Customers node from Columns Layout to Rows Layout. To accomplish this, click the down arrow that appears next to the Customers node. Then, from the drop-down list, click Rows Layout.

  2. Change the layout of the Details Column from Rows Layout to Columns Layout. To accomplish this, click the down arrow that appears next to the Details Column node, and then click Columns Layout.

By default, the area of the screen that displays the details of a customer named Details Column displays all of the fields from the data source. If you do not want all of the fields to appear, you can remove the ones you do not want. For example, the following steps show how to remove the Country field.

To remove fields from a screen

  1. In the Screen Content Tree, expand the Customer Details node if it is not already expanded.

  2. Click the Country field, then, in the command bar of the Screen Designer, click Delete.

The following steps show how to change the display order of fields, for example, the CustomerID field and the Postal Code field.

To change the order of fields

  1. In the Screen Content Tree, expand the Customer Details node if it is not already expanded.

  2. To move the CustomerID field to the bottom of the details column, drag it under the Fax field.

  3. To move the Postal Code field to the position just above Customer ID, drag it between the Fax field and the CustomerID field.

You can customize how a field is displayed to the user. For example, you can set a text field to appear as either a TextBox or as a Label. The following steps show how to change a display field to a Label field so that the user cannot modify its value.

To change the control type of a field

  1. In the Screen Content Tree, expand the Customer Details node if it is not already expanded.

  2. Select the Customer ID field, and then in the drop-down list, select Label.

    You can repeat this step to change other fields.

  3. To test the changes, press F5 to run the application.

You can also customize a screen while the application is running. For example, you can remove fields, change the order of fields, and change properties such as control type or label alignment.

To customize a screen in a running application

  1. If your application is not already running, press F5 to start it.

  2. In the command bar of the screen, click Design Screen.

  3. In the Customization Mode screen, remove the Customer ID field from the details column by selecting it in the Customer Details node and then clicking the Delete (Deletes the selected item.) button.

  4. Move the Fax field under the Postal Code field by selecting it in the Customer Details node and then clicking the Move Down (Moves an item to a position lower in the list.) button.

  5. Change the name of the Phone field to Phone Number by selecting it in the Customer Details node and then, in the Properties window, change the value of the Display Name property to Phone Number.

  6. Change the display type of the Phone Number field to a Label by selecting the field in the Customer Details node and then, in the Properties window, clicking the Control Type property and selecting the Label value.

  7. Change the alignment of the labels in the details column. Select the first field in the Customer Details node, in this case, the Company Name field. In the Properties window, click the Label Position property and select the Right-aligned value. Repeat this step for all of the fields in the Customer Details node.

  8. To save your changes, click Save. Your application now displays the changes that you just made.

By default, when you select a data source for a screen, all the data in the source is displayed. If you only want to display a subset of the data, you can create a query to define the data to display. For more information, see How to: Design a Query by Using the Query Designer.

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

Community Additions

Show:
© 2015 Microsoft