關注此主題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的排序列表中列出