隐马尔可夫模型。。。怎么样:
<ListView Name="listView" SelectionChanged="listView_SelectionChanged" DataContextChanged="listView_DataContextChanged" />
在SelectionChanged处理程序中,将SelectedItem保存在ListView的标记中
private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
(sender as ListView).Tag = (sender as ListView).SelectedItem;
}
ListView的DataContext更改后,根据新集合计算保存在标记中的最后一个SelectedItem,并从该集合中设置新项:
private void listView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
List<CustomClass> newList = e.NewValue as List<CustomClass>;
if (newList != null && (sender as ListView).Tag != null)
{
foreach (CustomClass cClass in newList)
if (cClass.Equals((sender as ListView).Tag as CustomClass))
(sender as ListView).SelectedItem = cClass;
}
}