This article explains how a Detail Screen is created by a programmer as well as how a Detail Screen is generated in a LightSwitch Application (Visual C#) in Visual Studio 2012.
The following is the procedure for a programmer to create a LightSwitch Detail Screen.
Step 1
Open the Solution Explorer.
Step 2
In the Solution Explorer, right-click on the Server and choose "Add Table" option.
Step 3
The Person Table appears.
Step 4
In the Solution Explorer, right-click on the Screens and choose "Add Screen".
Step 5
The Add New Screen dialog box appears. Select the "New Data Screen" from the Screen Template, under screen information, choose "Person" under screen data and provide a name to the Screen, and click the "OK" button.
The Screen Designer appears for the New Data Screen.
Step 6
Add another screen. This time we will add a Detail Screen for the Person Table. Remember to uncheck the checkbox "Use as Default Detail Screen" when we add a Detail Screen.
The Screen Designer appears for the Details Screen.
Step 7
Open the Screen Designer for the New Data Screen and go to the menu bar and choose the "Write Code" drop down list item and then choose the "_Saved()" method.
The code designer appears. In this we need not change anything, the code will be added automatically.
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
namespace LightSwitchApplication
{
public partial class CreateNewPerson
{
partial void CreateNewPerson_InitializeDataWorkspace(global::System.Collections.Generic.List<global::Microsoft.LightSwitch.IDataService> saveChangesTo)
{
// Write your code here.
this.PersonProperty = new Person();
}
partial void CreateNewPerson_Saved()
{
// Write your code here.
this.Close(false);
Application.Current.ShowDefaultScreen(this.PersonProperty);
}
}
}
Step 8
Press F5 to run the application.
Step 9
Now make some changes in the code as in the following:
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
namespace LightSwitchApplication
{
public partial class CreateNewPerson
{
partial void CreateNewPerson_InitializeDataWorkspace(global::System.Collections.Generic.List<global::Microsoft.LightSwitch.IDataService> saveChangesTo)
{
// Write your code here.
this.PersonProperty = new Person();
}
partial void CreateNewPerson_Saved()
{
// Write your code here.
this.Close(false);
Application.Current.ShowPersonDetail(this.PersonProperty.Id);
}
}
}
Step 10
Now once again, press F5 to run the application.