If we're selecting a particular tree view item, then materialize and expand the item's ancestors as `SelectionModel` requests children. Only do this if a particular item is being selected, not when an item is selected as part of a range select.
To do this, needed to add a `FinalIndex` property to `SelectionModelChildrenRequestedEventArgs` in order to know if we're selecting a descendent of the item whose children are being requested.
This is a massive hack, but I can't think of a better way to do it with the current `TreeView` implementation.
`SelectionModel` can have a selection set before its `Source` is initialized. In this case, be sure to trim invalid selections from the model before continuing.
Fixes#3919
Make sure the item we're selecting is within the requested range. Also refactored the unit tests to do a simple test on `SelectedIndices` instead of using `IsSelectedWithPartial` because both can't really be tested together using the old testing method.
Make `SelectionModelChildrenRequestedEventArgs.Children` an observable, so that the we can react to the children collection object changing, as well as the children inside the collection changing.
Upstream issue: https://github.com/microsoft/microsoft-ui-xaml/issues/2404
`SelectionModel` as ported from WinUI has no information about what changed in a `SelectionChanged` event. This adds that information along with unit tests.
`SelectionModel` as ported from WinUI has no information about what changed in a `SelectionChanged` event. This adds that information along with unit tests.
- #nullable enable
- Make it a `readonly struct`
- Most of the time it will only hold a single `int`, so optimize for the common case by having an `int _index` field
- Make `_path` an array rather than a list as it will be fixed-size
- Implement equality
- Implement operators