Picker

Select a typed item from a native menu and keep it synchronized with a view model.

Picker<TItem> presents a collection of typed items through a native menu. It is a good fit for compact, single-choice settings where all options can be read at once.

The two-way SelectedItem example uses the binding form documented in MVVM and binding.

var qualityPicker = new Picker<ExportQuality>
{
    ItemsSource = viewModel.Qualities,
    ItemTitle = quality => quality.DisplayName,
    Placeholder = "Choose quality",
    SelectedItem = Bind(vm => vm.SelectedQuality)
        .TwoWay((vm, val) => vm.SelectedQuality = val)
};

ItemsSource is a BindableList<TItem>. Assigning an observable collection keeps the menu current as items are inserted, removed, or replaced. ItemTitle supplies the visible label; without it, the picker uses each item's ToString() result.

Selection

SelectedItem is bindable and supports two-way binding. You can also react directly:

qualityPicker.SelectionChanged = quality =>
{
    preview.Quality = quality;
};

Selection is matched by object reference. If a collection is reloaded with new object instances, select the corresponding new item rather than retaining an instance from the old collection.

The picker displays Placeholder whenever no selected item belongs to the current source. A useful initial-state pattern is to set the source first, then choose its default item in the view model.