私の問題を示す簡単な例が 2 つあります。
シナリオ 1 を実行すると、拡張選択モードを使用してアイテムを選択することで、通常どおりリスト ビューをナビゲートできます。
シナリオ 2 を実行すると、リスト ビューの移動が遅くなり、アイテムの選択が正しく機能しないことがわかりました。説明するのは難しいですが、それは、ほとんどの場合、クリックしてもカーソルの下の項目が選択されないということです。
何か案は?
1.1000項目のリストビューを静的に定義する
<Window x:Class="WpfApplication1.StaticListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="StaticListView" Height="300" Width="300">
<Grid>
<ListView Name="listView" SelectionMode="Extended">
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
<ListViewItem Content="bla" />
....
2. 1000 項目のリストにデータバインドされたリスト ビューを定義する
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for TestManyItemsInListView.xaml
/// </summary>
public partial class BoundListView : Window
{
public BoundListView()
{
InitializeComponent();
List<string> items = new List<string>();
AddItems(items);
listView.ItemsSource = items;
}
public void AddItems(List<string> items)
{
while (items.Count < 1000)
{
items.Add("bla");
}
}
}
}