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.
Methodology
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’.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.
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
- New
- CustomerId_Changed
- CustomerDetail_InitializeDataWorkspace
- CustomerDetail_Created
- CustomerDetail_Activated
- Customer_Validate
- CustomerId_Validate
- Customer_Loaded
Order of Events when changing a field and clicking ‘Save’
- CustomerDetail_Saving
- Customer_Validate
- CustomerId_Validate
- Finalize
Order of Events when closing a screen with no changes
- CustomerDetail_Closing
- Finalize
Order of Events when closing a screen with unsaved changes and choosing to discard
- CustomerDetail_Closing
- Finalize
Order of Events when closing a screen with unsaved changes and choosing to 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.For more detailed screen shots please click here
No comments:
Post a Comment