Class DataGridColumn
Represents a DataGrid column.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.Controls.Data.dll
Syntax
[StyleTypedProperty(Property = "CellStyle", StyleTargetType = typeof(DataGridCell))]
[StyleTypedProperty(Property = "DragIndicatorStyle", StyleTargetType = typeof(ContentControl))]
[StyleTypedProperty(Property = "HeaderStyle", StyleTargetType = typeof(DataGridColumnHeader))]
public abstract class DataGridColumn : DependencyObject
Constructors
| Improve this Doc View SourceDataGridColumn()
Initializes a new instance of the DataGridColumn class.
Declaration
protected DataGridColumn()
Properties
| Improve this Doc View SourceActualWidth
Actual visible width after Width, MinWidth, and MaxWidth setting at the Column level and DataGrid level have been taken into account
Declaration
public double ActualWidth { get; }
Property Value
Type | Description |
---|---|
System.Double |
CanUserReorder
Gets or sets a value that indicates whether the user can change the column display position by dragging the column header.
Declaration
public bool CanUserReorder { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the user can drag the column header to a new position; otherwise, false. The default is the current CanUserReorderColumns property value. |
CanUserResize
Gets or sets a value that indicates whether the user can adjust the column width using the mouse.
Declaration
public bool CanUserResize { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the user can resize the column; false if the user cannot resize the column. The default is the current CanUserResizeColumns property value. |
CanUserSort
Gets or sets a value that indicates whether the user can sort the column by clicking the column header.
Declaration
public bool CanUserSort { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the user can sort the column; false if the user cannot sort the column. The default is the current CanUserSortColumns property value. |
CellStyle
Gets or sets the style that is used when rendering cells in the column.
Declaration
public Style CellStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The style that is used when rendering cells in the column. The default is null. |
ClipboardContentBinding
The binding that will be used to get or set cell content for the clipboard.
Declaration
public virtual Binding ClipboardContentBinding { get; set; }
Property Value
Type | Description |
---|---|
Binding |
DisplayIndex
Gets or sets the display position of the column relative to the other columns in the DataGrid.
Declaration
public int DisplayIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The zero-based position of the column as it is displayed in the associated DataGrid. The default is the index of the corresponding System.Collections.ObjectModel.Collection<T>.Item[System.Int32] in the Columns collection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | When setting this property, the specified value is less than -1 or equal to System.Int32.MaxValue. -or- When setting this property on a column in a DataGrid, the specified value is less than zero or greater than or equal to the number of columns in the DataGrid. |
System.InvalidOperationException | When setting this property, the DataGrid is already making DisplayIndex adjustments. For example, this exception is thrown when you attempt to set DisplayIndex in a ColumnDisplayIndexChanged event handler. -or- When setting this property, the specified value would result in a frozen column being displayed in the range of unfrozen columns, or an unfrozen column being displayed in the range of frozen columns. |
DragIndicatorStyle
Declaration
public Style DragIndicatorStyle { get; set; }
Property Value
Type | Description |
---|---|
Style |
Header
Declaration
public object Header { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
HeaderStyle
Declaration
public Style HeaderStyle { get; set; }
Property Value
Type | Description |
---|---|
Style |
IsAutoGenerated
Declaration
public bool IsAutoGenerated { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsFrozen
Declaration
public bool IsFrozen { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReadOnly
Declaration
public bool IsReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxWidth
Declaration
public double MaxWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
MinWidth
Declaration
public double MinWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
SortMemberPath
Holds the name of the member to use for sorting, if not using the default.
Declaration
public string SortMemberPath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Visibility
Declaration
public Visibility Visibility { get; set; }
Property Value
Type | Description |
---|---|
Visibility |
Width
Declaration
public DataGridLength Width { get; set; }
Property Value
Type | Description |
---|---|
DataGridLength |
Methods
| Improve this Doc View SourceCancelCellEdit(FrameworkElement, Object)
When overridden in a derived class, causes the column cell being edited to revert to the unedited value.
Declaration
protected virtual void CancelCellEdit(FrameworkElement editingElement, object uneditedValue)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | editingElement | The element that the column displays for a cell in editing mode. |
System.Object | uneditedValue | The previous, unedited value in the cell being edited. |
GenerateEditingElement(DataGridCell, Object)
When overridden in a derived class, gets an editing element that is bound to the column's Binding property value.
Declaration
protected abstract FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
Parameters
Type | Name | Description |
---|---|---|
DataGridCell | cell | The cell that will contain the generated element. |
System.Object | dataItem | The data item represented by the row that contains the intended cell. |
Returns
Type | Description |
---|---|
FrameworkElement | A new editing element that is bound to the column's Binding property value. |
GenerateElement(DataGridCell, Object)
When overridden in a derived class, gets a read-only element that is bound to the column's Binding property value.
Declaration
protected abstract FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
Parameters
Type | Name | Description |
---|---|---|
DataGridCell | cell | The cell that will contain the generated element. |
System.Object | dataItem | The data item represented by the row that contains the intended cell. |
Returns
Type | Description |
---|---|
FrameworkElement | A new, read-only element that is bound to the column's Binding property value. |
GetCellContent(Object)
Declaration
public FrameworkElement GetCellContent(object dataItem)
Parameters
Type | Name | Description |
---|---|---|
System.Object | dataItem |
Returns
Type | Description |
---|---|
FrameworkElement |
GetCellContent(DataGridRow)
Declaration
public FrameworkElement GetCellContent(DataGridRow dataGridRow)
Parameters
Type | Name | Description |
---|---|---|
DataGridRow | dataGridRow |
Returns
Type | Description |
---|---|
FrameworkElement |
GetColumnContainingElement(FrameworkElement)
Returns the column which contains the given element
Declaration
public static DataGridColumn GetColumnContainingElement(FrameworkElement element)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | element | element contained in a column |
Returns
Type | Description |
---|---|
DataGridColumn | Column that contains the element, or null if not found |
NotifyPropertyChanged(String)
Called by a specific column type when one of its properties changed, and its current cells need to be updated.
Declaration
protected void NotifyPropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Indicates which property changed and caused this call |
PrepareCellForEdit(FrameworkElement, RoutedEventArgs)
When overridden in a derived class, called when a cell in the column enters editing mode.
Declaration
protected abstract object PrepareCellForEdit(FrameworkElement editingElement, RoutedEventArgs editingEventArgs)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | editingElement | The element that the column displays for a cell in editing mode. |
RoutedEventArgs | editingEventArgs | Information about the user gesture that is causing a cell to enter editing mode. |
Returns
Type | Description |
---|---|
System.Object | The unedited value. |
RefreshCellContent(FrameworkElement, String)
Called by the DataGrid control when a column asked for its elements to be refreshed, typically because one of its properties changed.
Declaration
protected virtual void RefreshCellContent(FrameworkElement element, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
FrameworkElement | element | Indicates the element that needs to be refreshed |
System.String | propertyName | Indicates which property changed and caused this call |