Table of Contents

ReferenceSelected

This rule is triggered when a reference is selected via the "Lookup" component.

Unlike the "PropertyChanged" event rule, this rule is triggered even if the selected value is the same as the current value.

It can be used, for example, to fill a property with a property of the selected reference.

The event rule is executed by filter bar lookups. This is why Item is nullable.

Arguments

The Arguments property provides the following options.

Name Type Description
Item The type of the UI view model Instance on which the lookup is bound.
Value object Selected reference.

Item versus DatasourceCurrent

To know more on the difference between the Item and DatasourceCurrent properties in an UI view event rule, you can check this article.

Examples

Let's imagine a lookup on a property representing the zip code. The persisted value is the zip code.

There may be several cities with the same zip code. The suggestions proposed by the lookup can be :

Zip code City
31530 THIL
31530 SAINT-LIVRADE
31530 MENVILLE

If we want to feed a "City" property once the user has selected a suggestion, we could use the "PropertyChanged" event rule.

if (Arguments.SelectedLookupItem != null)
{
    Item.City = ((PostalCodeLookupUI)Arguments.SelectedLookupItem).City;
}
else
{
    Item.City = null;
}

However, if the user selects another suggestion with the same current postal code, the "PropertyChanged" event rule will not be retriggered, as the new postal code is the same as the current postal code.

To handle this case, you can use the "ReferenceSelected" event rule:

if (Item != null)
{
    if (Arguments.Value != null)
    {
        Item.City = ((PostalCodeLookupUI)Arguments.Value).City;
    }
    else
    {
        Item.City = null;
    }
}