Overview of Article
There are various screen events available in LightSwitch. At the moment, there isn’t very much documentation specifying the order in which these events fire.
The following post documents my findings in relation to the ordering of events.
Having created a details screen based on a ‘Customer’ entity, this is a typical screen which is created by default. The name of the screen is ‘CustomerDetail’ and the name of the Customer entity is ‘Customer’.
Fig 1 Illustration of Details screen
The following screenshot shows the available events. There are 3 property/entity events and 7 screen events. ‘CustomerId’ is the name of the property that relates to the screen parameter.
Fig 2 Events that are available
In order to work out the order in which these events fire, I’ve written some code showing a message box on each event. Here are my findings:
Order of events when opening a screen
Order of Events when changing a field and clicking ‘Save’
Order of Events when closing a screen with no changes
Order of Events when closing a screen with unsaved changes and choosing to discard
Order of Events when closing a screen with unsaved changes and choosing to save
Dialog now appears – we choose ‘Save’
As a final note, the CustomerDetail_Activated will fire whenever you change focus to another screen and return to it. Hopefully, this post sheds a bit more light into the ordering of events.