Home > Articles > Programming > Visual Studio

  • Print
  • + Share This
From the author of Implementing a Home Screen

Implementing a Home Screen

Out of the box, LightSwitch doesn't offer a screen template to create a home screen, which would be useful to introduce users to the application and to provide shortcuts to screens or additional resources. If you have experience with Microsoft Access, you might recall the command panel forms where you could add buttons and launch tasks; in LightSwitch, something similar would certainly be interesting.

But it's quite easy to make a home screen of your own. Continuing the previous discussion of how to add static images to an empty screen, we can extend the screen with some text and commands. Figure 8 shows the result that you'll reach moments from now.

Basically you'll need to do the following:

  1. Add a new group of type Rows Layout under the logo.
  2. Add a Local Property of type String called WelcomeMessage and place it inside the previous group. This property will contain an informational message. Change the Font Style property to Heading 1.
  3. Add a new group of type Tabs Layout under the Rows Layout created earlier (but don't make it nested).
  4. Add a new group called Columns Layout inside the Tabs Layout. Change the value of the Display Name property to Tasks.
  5. Add two buttons inside the Command Bar of the Columns Layout. Change their appearance to Hyperlink.
  6. Update the InitializeDataWorkspace method hook to assign the WelcomeMessage property:
  7. Private Sub Home_InitializeDataWorkspace(saveChangesTo As System.Collections.
                Generic.List(Of Microsoft.LightSwitch.IDataService))
        Me.CustomLogo = GetImageByName("CompanyLogo.png")
        Me.WelcomeMessage = "Welcome to the Fantastic Company's application"
    End Sub
  8. The next step is handling the Execute method hook of each button. Depending on the name you've given to the buttons' methods, write code similar to the following:
  9. Private Sub OpenScreenOne_Execute()
    End Sub

    Replace OpenScreenOne with the name of your button and ShowScreenOne with the method that will open the appropriate screen.

  10. Run the application. You'll get a result similar to what you see in Figure 9.

This is just an example of how you can create and customize a home screen for your applications.

  • + Share This
  • 🔖 Save To Your Account