private void GroupFileList(object parameters) { var query = MediaFiles.GroupBy(mf => mf.Type).Select(g => new { Name = g.Key, Files = g.ToList <MediaFile>() }).ToList(); MediaFiles.Clear(); foreach (var mf in query) { MediaFiles.Add(new MediaFile { Name = mf.Name.ToString() }); foreach (MediaFile f in mf.Files) { MediaFiles.Add(f); } } }