public static Dictionary <object, object> GroupData(ICollectionView cv) { Dictionary <object, object> groupedData = new Dictionary <object, object>(); var lr = cv as System.Windows.Data.ListCollectionView; if (lr.Groups != null) { foreach (var group in lr.Groups) { System.Windows.Data.CollectionViewGroup cvGroup = group as System.Windows.Data.CollectionViewGroup; List <object> dstItems = new List <object>(); groupedData.Add(cvGroup.GetName(), dstItems); foreach (var item in cvGroup.Items) { dstItems.Add(item); } } } else { List <object> dstItems = new List <object>(); groupedData.Add("", dstItems); foreach (var item in cv.SourceCollection) { dstItems.Add(item); } } return(groupedData); }
/// <summary> /// Extension method to convert a ICollectionView to a List /// </summary> public static IList <T> ViewToList <T>(this System.ComponentModel.ICollectionView view) { IList <T> resList = new List <T>(); var lr = view as System.Windows.Data.ListCollectionView; if (view.Groups != null) { foreach (var group in view.Groups) { System.Windows.Data.CollectionViewGroup cvGroup = group as System.Windows.Data.CollectionViewGroup; // Group(Name) would be: cvGroup.Name.ToString() foreach (var item in cvGroup.Items) { resList.Add((T)item); } } } else { foreach (var item in view.SourceCollection) { resList.Add((T)item); } } return(resList); }
/// <summary> /// Gives a string representation of this object. /// </summary> /// <returns></returns> internal override string GetPlainText() { System.Windows.Data.CollectionViewGroup cvg = Content as System.Windows.Data.CollectionViewGroup; if (cvg != null && cvg.Name != null) { return(cvg.Name.ToString()); } return(base.GetPlainText()); }
public static string GetName(this System.Windows.Data.CollectionViewGroup cvGroup) { string groupName = string.Empty; if (cvGroup?.Name != null) { groupName = cvGroup.Name.ToString(); } return(groupName); }
public void Visit(DataGridContext sourceContext, System.Windows.Data.CollectionViewGroup group, object[] namesTree, int groupLevel, bool isExpanded, bool isComputedExpanded, ref bool stopVisit) { throw new NotSupportedException("The RangeSelectionVisitor is only capable of handling data items block."); }
GroupStyle MS.Internal.Controls.IGeneratorHost.GetGroupStyle(System.Windows.Data.CollectionViewGroup group, int level) { return(default(GroupStyle)); }