This may sound simple but the solution code is not. To close a screen from another screen you need to write three lines of code including one dispatcher. The steps are as follows:
1. Create a variable IActiveScreen
Dim ChosenScreen As Microsoft.LightSwitch.Client.IActiveScreen
2. Query the active screens. In my code sample below the screen name that I will be closing is sysTransaction.
ChosenScreen = Application.ActiveScreens.Where(Function(a) TypeOf a.Screen Is sysTransaction).FirstOrDefault()
3. Now make a dispatcher to execute an event. Our event is to close the chosen screen.
ChosenScreen.Screen.Details.Dispatcher.BeginInvoke(Sub() DirectCast(ChosenScreen.Screen, sysTransaction).Close(False) End Sub)
That’s it. By the way, I haven’t tried this code on multiple screen instances, since most of my screen are set to single instant only.
Furthermore you can also use the dispatcher to refresh the choosen screen.