partial void OnApplyTemplatePartial() { // NativePanel may not exist if we're using a non-virtualizing ItemsPanel. if (NativePanel != null) { // Propagate the DataContext manually, since ItemsPanelRoot isn't really part of the visual tree ItemsPanelRoot.SetValue(DataContextProperty, DataContext, DependencyPropertyValuePrecedences.Inheritance); if (ScrollViewer?.Style == null) { throw new InvalidOperationException($"Performance hit: {this} is using a ScrollViewer in its template with a default style, which would break virtualization. A Style containing {nameof(ListViewBaseScrollContentPresenter)} must be used."); } if (ScrollViewer != null) { NativePanel.HorizontalScrollBarVisibility = ScrollViewer.HorizontalScrollBarVisibility; NativePanel.VerticalScrollBarVisibility = ScrollViewer.VerticalScrollBarVisibility; } } else { if (ScrollViewer?.Style != null && ScrollViewer.Style == ResourceResolver.GetSystemResource <Style>("ListViewBaseScrollViewerStyle")) //TODO: this, too, properly { // We're not using NativeListViewBase so we need a 'real' ScrollViewer, remove the internal custom style ScrollViewer.Style = null; } } }