[]
Gets the FrameworkElement used to represent a cell on the panel.
public FrameworkElement GetCellElement(CellRange rng)
Type | Name | Description |
---|---|---|
CellRange | rng | CellRange to locate. |
Type | Description |
---|---|
FrameworkElement | A FrameworkElement used to represent a cell on the panel. |
<p>The default class factory uses <xref href="System.Windows.Controls.Border" data-throw-if-not-resolved="false"></xref> elements to represent
all cells. The border is responsible for rendering the cell's background color and the gridlines. The border contains the elements that represent the cell's actual content. In most cases, the border child is a simple TextBlock or CheckBoxelement that displays the cell content. Cells that contain text and graphics (e.g. sorted column headers and group rows) host a Grid element that contains the text and graphics elements.
This method can be useful in cases where you want to customize a cell after it has been created by the cell factory.
This method returns null if the requested range is not within the current view (see the ViewRange property), or if the requested range does not match exactly the range represented by the cell (if the range is merged for example).
The code below turns the selected cells red:
// loop through the cells in the current selection
foreach (var cell in _flex.Selection.Cells)
{
// get element used to represent the cell
var bdr = _flex.Cells.GetCellElement(cell) as Border;
if (bdr != null)
{
// make it red
bdr.Background = new SolidColorBrush(Colors.Red);
}
}