Gets the FrameworkElement used to represent a cell on the panel.

Namespace:  C1.Silverlight.FlexGrid
Assembly:  C1.Silverlight.FlexGrid.4 (in C1.Silverlight.FlexGrid.4.dll)

Syntax

C#
public FrameworkElement GetCellElement(
	CellRange range
)
Visual Basic
Public Function GetCellElement ( _
	range As CellRange _
) As FrameworkElement

Parameters

range
Type: C1.Silverlight.FlexGrid..::..CellRange
CellRange to locate.

Return Value

A FrameworkElement used to represent a cell on the panel.

Remarks

The default class factory uses Border 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).

Examples

The code below turns the selected cells red:
Copy CodeC#
// 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);
  }
}

See Also