Creating a UI view event rule
What are UI view event rules ?
UI view event rules are sets of code whose execution is triggered by events in the client application.
Unlike entity view event rules which are executed on the server side, UI view event rules are meant to exploit data entered by the user and add business logic into the user interface.
Writing rule code
When writing an event rule code, the this object represents the ViewModel object.
This object allows you to exploit the data of the UI view, for example, to :
- set new values to properties
- change visibility of specific properties
- disable specific inputs
- call actions
- ...
For some event rules, you also have an Arguments object which properties are detailed in the next section.
Available rules
Several rules are available in a UI view. This section is an exhaustive list of these rules.
- Initialized
- Retrieving
- Retrieved
- ItemAdding
- ItemAdded
- Removing
- ItemRemoving
- ItemRemoved
- DataSaving
- DataSaved
- PropertyChanged
- PositionChanging
- PositionChanged
- ItemSelectionChanging
- ItemSelectionChanged
- Navigating
- Closing
- ReferenceRetrieving
- ReferenceSelected
- ItemCloning
- Disposed
Global event rules
There are also global events running on all UI views.
You can subscribe to these events in an initialization UI shared method.
The UI shared method class must be named AppInitialization. The UI shared methods in the AppInitialization class are executed at application startup.
Initialized
The event is executed when a UI view initializes.
The event is executed before the Initialized event rule of the UI view.
UIViewEvents.Initialized.AddHandler((args) =>
{
ViewModel viewModel = args.ViewModel;
// ...
});
In the arguments, there is only the view model of the UI view.
LayoutUpdated
The event is executed when the layout of a UI view is updated.
It is used by the UICustomization module to save the custom view automatically each time the layout is updated.
UIViewEvents.LayoutUpdated.AddHandler((args) =>
{
ViewModel viewModel = args.ViewModel;
// ...
});
In the arguments, there is only the view model of the UI view.