// bind a cell to a range public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range) { // get row/col var row = grid.Rows[range.Row]; var col = grid.Columns[range.Column]; var gr = row as GroupRow; // no border for group rows if (gr != null) { bdr.BorderThickness = _emptyThickness; } // bind the tree cells if (gr != null && range.Column == 0) { BindGroupRowCell(grid, bdr, range); return; } // bind cells in regular data rows var colName = col.ColumnName; if (colName == "Name") { bdr.Child = new SongCell(row); return; } if (colName == "Rating") { var song = row.DataItem as Song; if (song != null) { // create rating control to represent this cell // notes: // - the data context is provided by the Border element, and // - the binding is provided by the column var cell = new RatingCell(); cell.SetBinding(RatingCell.RatingProperty, col.Binding); bdr.Child = cell; return; } } // default binding base.CreateCellContent(grid, bdr, range); }
// bind a cell to a range public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range) { // get row/col var row = grid.Rows[range.Row]; var col = grid.Columns[range.Column]; var gr = row as GroupRow; // no border for group rows if (gr != null) { bdr.BorderThickness = _emptyThickness; } // bind first cell in each group row to collapse/expand if (gr != null && range.Column == 0) { BindGroupRowCell(grid, bdr, range); return; } // bind regular data cells switch (col.ColumnName) { // show names with images case "Name": bdr.Child = new SongCell(row); return; // show ratings with stars case "Rating": var song = row.DataItem as Song; if (song != null && gr == null) { var cell = new RatingCell(); cell.SetBinding(RatingCell.RatingProperty, col.Binding); bdr.Child = cell; } return; } // default binding base.CreateCellContent(grid, bdr, range); }