public void FillProxy() { this.Clear(); ViewTypes = _root.SelectMany(x => x).Select(x => x.GetType()).Distinct() .Select((type, idx) => new { type, index = idx }) .ToDictionary(key => key.type, val => val.index + Enum.GetNames(typeof(ViewType)).Length); int sectionCount = _model.GetSectionCount(); for (var sectionIndex = 0; sectionIndex < sectionCount; sectionIndex++) { var sectionRowCount = _model.GetRowCount(sectionIndex); var isTextHeader = _model.GetSectionHeaderView(sectionIndex) == null; var curSection = _model.GetSection(sectionIndex); this.Add(new RowInfo { Section = curSection, ViewType = isTextHeader ? ViewType.TextHeader : ViewType.CustomHeader, }); for (int i = 0; i < sectionRowCount; i++) { var cell = _model.GetCell(sectionIndex, i); this.Add(new RowInfo { Section = curSection, Cell = cell, ViewType = (ViewType)ViewTypes[cell.GetType()], }); } var isTextFooter = _model.GetSectionFooterView(sectionIndex) == null; this.Add(new RowInfo { Section = curSection, ViewType = isTextFooter ? ViewType.TextFooter : ViewType.CustomFooter, }); } }