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.
And remove child selection when a `TreeViewItem` is un-expanded.
This is necessary because we don't get enough information about a materialized `TreeViewItem` to select it when materialized, so the `SelectionModel` and `TreeViewItem` selection state gets out of sync.
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
As described in #3437 the argument ordering was different to WPF/UWP causing bugs in some code ported from WPF/UWP. Use the same argument ordering as WPF/UWP.
Fixes#3437
As described in #3437 the argument ordering was different to WPF/UWP causing bugs in some code ported from WPF/UWP. Use the same argument ordering as WPF/UWP.
Fixes#3437
Update `TreeItemContainerGenerator.Index` when a `TreeViewItem` is added to or removed from the logical tree. This ensures that removed `TreeViewItem`s won't try to add duplicate containers to the index.
Fixes#2985
Calling the overload of `SetAndRaise` which takes a callback should not be necessary because that was only needed in `SelectingItemsControl` due to the interaction between `SelectedIndex` and `SelectedItem`.