ListViewのサブクラス化を必要とする別の回避策があります。少し手間がかかりますが、最初の項目までスクロールするよりも良い結果が得られます。ただし、テンプレート内のScrollViewerに名前(ここではPART_ScrollViewer)が付けられるように、ListViewテンプレートを調整するか、別の方法を使用してScrollViewerオブジェクトを取得する必要があります。
public class BetterListView : ListView
{
ScrollViewer sv;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
//Get the scrollviewer in the template (I adapted the ListView template such that the ScrollViewer has a name property)
sv = (this.Template.FindName("PART_ScrollViewer", this)) as ScrollViewer;
}
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
//Prevent the bug where the ListView doesn't scroll correctly when a lot of items are removed
if (sv != null && e.Action == NotifyCollectionChangedAction.Remove)
{
sv.InvalidateScrollInfo();
}
}
}