When we set the DataContext, we save that fact in the VirtualizationInformation for that element, when that element gets cleared, we look up in the VirtualizationInformation whether we should need to clear the DataContext too, and do that if necessary.
Ported from e9bd88e598
- Make sure an anchor is a descendent of the `ScrollContentPresenter` when added
- Ignore controls that are no longer descendents of the `ScrollContentPresenter` when evaluating
- Change the hack we're using to find the effective viewport in `ViewportManager`
- Unregister anchor candidates when bringing an item into view
- Adjust `ScrollContentPresenter` extent when tracking an anchor, if the adjustment causes the offset to go out of bounds of the extent
- Simplify coercing `Offset` in `ScrollViewer`
When `Offset` is adjusted due to scroll ancoring during the arrange pass in `ScrollContentPresenter`, don't invalidate the arrange: we've got it handled.
When a layout of a control exceeds the maximum passes and we re-queue it, reset the attempt count to 0 because otherwise it can end up stuck in the layout queue forever even when the next layout can succeed with e.g. 2 passes. This can happen with `ItemsRepeater`.
Instead of simply reading old `TranslatedBounds` value when `Bounds` changes, use the clip and transform from the previous `TranslatedBounds` with the new `Bounds`.
`OnEffectiveViewportChanged` needs to be triggered first, otherwise `_makeAnchorElement` is cleared too early, breaking scrolling in a list with variable-height items.
When transitions are replaced, add the new transitions before removing the old transitions, so that when the old transition being disposed causes the value to change, there is a corresponding entry in `_transitionStates`.
Also search the `Transitions` collection from last to first to find a matching transition, so that later added transitions have priority.
Fixes#4059