Version

SelectedItemsChanged Event

Occurs after the SelectedItems have changed.
Syntax
'Declaration
 
Public Event SelectedItemsChanged As EventHandler(Of SelectedItemsChangedEventArgs)
public event EventHandler<SelectedItemsChangedEventArgs> SelectedItemsChanged
Event Data

The event handler receives an argument of type SelectedItemsChangedEventArgs containing data related to this event. The following SelectedItemsChangedEventArgs properties provide information specific to this event.

PropertyDescription
Handled (Inherited from System.Windows.RoutedEventArgs)Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource (Inherited from System.Windows.RoutedEventArgs)Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
RoutedEvent (Inherited from System.Windows.RoutedEventArgs)Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source (Inherited from System.Windows.RoutedEventArgs)Gets or sets a reference to the object that raised the event.
Type Returns the type of object that triggered the selection change (read-only).
Remarks

Three types of items can be selected, Records, Cells and Fields. This functionality is controlled by the following properties:

The SelectedItems object exposes 3 collections (DataPresenterBase.SelectedItemHolder.Records, DataPresenterBase.SelectedItemHolder.Cells and DataPresenterBase.SelectedItemHolder.Fields) that can can be used to select/de-select specific items. In addition, selection can be affected by setting the Record's Record.IsSelected, the Cell's Cell.IsSelected and the Field's Field.IsSelected properties.

The following describes how selection behaves in various scenarios:

  • If a user selects records, cells or fields via mouse or keyboard interactions then the SelectedItemsChanging event is raised. If this is not canceled then the appropriate SelectedItems collections are updated and the SelectedItemsChangingSelectedItemsChanged events are raised
  • If any of the IsSelected properties are changed in code or items are added or removed via the SelectedItems collections then the behavior is the same and the SelectedItemsChanging and SelectedItemsChanged events are raised.
  • If the user enters edit mode on a cell then all of the selected collections will be cleared triggering the same SelectedItemsChanging and SelectedItemsChanged events.
  • When records are deleted (either thru changes to the data source or by the user pressing the 'Delete' key) the SelectedItemsChanging event will not be raised even though the SelectedItemsRecords and Cells collections are updated appropriately. However, the SelectedItemsChanged event will be raised. Note if the data source supports deleting records and FieldLayoutSettings.FieldLayoutSettings.AllowDelete property is not set to 'False' then pressing the 'Delete' key will raise the RecordsDeleting event. If this is not canceled then by default the user will be prompted to confirm the deletion of all selected records.
  • If record filtering is active (i.e. FieldSettings.FieldSettings.AllowRecordFiltering is set to 'True' for one or more fields) then selection behaves as follows:
    • If a filter record is being displayed (i.e. FieldLayoutSettings.FieldLayoutSettings.FilterUIType is set to 'FilterRecord' or left to its default value) then entering a filter cell will behave the same as entering any other cell. It will clear the existing selection and raise the events.
    • If filtering is exposed via a drop down inside a field label (i.e. FieldLayoutSettings.FieldLayoutSettings.FilterUIType is set to 'LabelIcons') then changing the filter criteria will leave the existing selections unchanged. Therefore it is possible to, e.g. select 5 records then filter some of them out and then operate on the original 5 selected records. If the data source supports deleting records and FieldLayoutSettings.FieldLayoutSettings.AllowDelete property is not set to 'False' then pressing the 'Delete' key will prompt the user to confirm the deletion of the original 5 selected records. This behavior can be modified by e.g. canceling the RecordsDeleting event and deleting only the 'filtered in' records in code.

Note: Record and Cell selection is mutually exclusive. Selecting one or more Records will automatically clear the Cell selection and vice versa.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also