Skip to content

Add a way for SelectedItemsControl to keep the selected item even if it isn't present in the ItemsSource #18635

@MrJul

Description

@MrJul

Is your feature request related to a problem? Please describe.

Currently, as soon as SelectedItemsControl doesn't contain its SelectedItem/SelectedIndex/SelectedValue anymore, the selection is reset.

While we have various workarounds present to prevent selection from being changed too aggressively at init time (such as #18634), scenarios exist where it makes sense to have the selection uncorrelated from the items, notably for ComboBox.

For example, a common scenario is to have the ItemsSource loaded later. It could be on demand when the ComboBox opens, or loaded in chunks if the source is too large.

Describe the solution you'd like

A new property should be added to keep the existing selection, until the user explicitly interacts with it through the SelectingItemsControl.

Proposed names:

  • KeepSelection
  • AllowSelectionOutsideItems
  • AutoResetSelection (reverse behavior, true by default)

Describe alternatives you've considered

No response

Additional context

#18147, #18323 and probably others I can't find right now.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions