dotnet / dotnet/wpf

[API Proposal]: Expose SelectedItemsImplProperty in MultiSelector

Open
#8,490 1 comment 4 reactions 0 assignees View on GitHub
API suggestion
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Background and motivation

When inheriting from `MultiSelector`, it is currently not possible to use `SelectedItems` in bindings because the underlying `DependencyProperty` is not exposed.

### API Proposal

Add the following to `MultiSelector`.
The `ListBox` inherits from `Selector` and has this code.
```csharp
///
/// A read-only IList containing the currently selected items
///
public static readonly DependencyProperty SelectedItemsProperty = Selector.SelectedItemsImplProperty;
```

### API Usage

```xaml

```
Currently this will fail `error MC3011: Cannot find the static member 'SelectedItemsProperty' on the type 'MyMultiSelector'`

### Alternative Designs

At least make `SelectedItemsImplProperty` protected.
```csharp
protected internal static readonly DependencyProperty SelectedItemsImplProperty =
SelectedItemsPropertyKey.DependencyProperty;
```

### Risks

I don't think there are risks. The `ListBox` does the same thing.
Actually `ListBox` could inherit from `MultiSelector`. `ListBox` currently seems to duplicate the code in `MultiSelector`.
However the latter could pose some small risk, if existing code checks for `control is MultiSelector` and does not expect a `ListBox`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.