关注此主题Xceed WPF propertyGrid show item for expanded collection,当绑定到类时,XAML如何用Name对列表进行排序? 每次我想添加一个新的项目,它应该立即排序。它不起作用,因为如果我使用Classes.orderby(x => x.name)它打破所有绑定?在XAML的Propertygrid中排序列表
0
A
回答
0
如何重新创建一个新的可观察集合?
试试下面的代码:
Classes = new ObservableCollection<string>(Classes.OrderBy(x => x.name));
0
您好时间的解决方案是在同一时间,而不是大量的经过,但在这里,我给你所有的解决方案: 1)的getter和setter方法为您的ObservableCollection
private TheCollection yourcollection;
public TheCollection Yourcollection{
get{
yourcollection.CollectionChanged -= Your_CollectionChanged;
// use sort-Extension to sort pointprofil
yourcollection.Sort();
// read CollectionChange-Event
yourcollection.CollectionChanged += Your_CollectionChanged;
return yourCollection;
}
}
和你的收藏有从的ObservableCollection但同时继承得到一个扩展排序()
她Ë我们去:
static class Extensions
public static void Sort<T>(this ObservableCollection<T> collection) where T : IComparable
{
List<T> sorted = collection.OrderBy(x => x).ToList();
for (int i = 0; i < sorted.Count(); i++)
collection.Move(collection.IndexOf(sorted[i]), i);
}
}
public class YourCollections : ObservableCollection<YourPoints>, ICustomTypeDescriptor, INotifyPropertyChanged
{
}
和YourPoints必须从IComparable的
继承相关问题
- 1. PropertyGrid C中的列表#
- 2. PropertyGrid中的编辑列表
- 3. PropertyGrid属性列表
- 4. 在XAML中绑定列表的列表?
- 5. 在c中排序列表#
- 6. 在PHP中排序列表
- 7. 在C#中排序列表#
- 8. 在排序列表
- 9. 序列化PropertyGrid(SerializeToXML)失败
- 10. 如何仅在XAML的DataTemplate中对列表视图进行排序?
- 11. F#列表中的排序列表F#
- 12. 链接列表中的排序列表
- 13. 的PropertyGrid为Windows 8商店应用程序(的WinRT/XAML)
- 14. WPF Propertygrid与自定义排序
- 15. Python中的排序列表
- 16. elasticsearch中的列表排序
- 17. 排序列表中的Javascript
- 18. 在python列表中按升序排列
- 19. 在Python中排序列表的问题
- 20. 排序列表
- 21. 排序列表
- 22. 排序列表
- 23. 排序列表
- 24. 排序列表
- 25. 排序列表
- 26. 排序列表
- 27. 列表排序
- 28. 在排序列表中排序标题的问题
- 29. Python列表排序,列表
- 30. Python的排序列表中列出