0
我有一个名为ContactList的类,它有一个名为AggLabels的属性,它是一个Observable集合。当一个ContactList被填充时,AggLabels集合将包含一些重复的AggregatedLabels。有没有办法使用ListCollectionView通过“名称”将这些AggregatedLabels分组,以便在将集合绑定到WPF中的列表框时不显示重复项?在我的代码片段组中的ContactListName有没有一种方法可以修改这个来实现我的目标?由于ListCollectionView GroupDescription issue
ContactList
public class ContactList
{
public int ContactListID { get; set; }
public string ContactListName { get; set; }
public ObservableCollection<AggregatedLabel> AggLabels { get; set; }
}
AggregatedLabel
public class AggregatedLabel
{
public int ID { get; set; }
public string Name { get; set; }
}
代码段
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//TODO: Add event handler implementation here.
ListCollectionView lcv = new ListCollectionView(myContactLists);
lcv.GroupDescriptions.Add(new PropertyGroupDescription("ContactListName"));
contactsListBox.ItemsSource = lcv.Groups;
}
你能说清楚你的例子具体值在ContactList,AggLables和输出你期待? – 2011-01-24 21:02:40