Class DataGridColumn
Represents a Data
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, IDependencyObject
Constructors
| Improve this Doc View SourceDataGridColumn()
Initializes a new instance of the Data
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. |
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. |
true if the user can drag the column header to a new position; otherwise, false. The default is the current Can |
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. |
true if the user can resize the column; false if the user cannot resize the column. The default is the current Can |
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. |
true if the user can sort the column; false if the user cannot sort the column. The default is the current Can |
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 Data
Declaration
public int DisplayIndex { get; set; }
Property Value
Type | Description |
---|---|
System. |
The zero-based position of the column as it is displayed in the associated Data |
Exceptions
Type | Condition |
---|---|
System. |
When setting this property, the specified value is less than -1 or equal to System. -or- When setting this property on a column in a Data |
System. |
When setting this property, the Data -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
Gets or sets the style that is used to render the column while it is being dragged.
Declaration
public Style DragIndicatorStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The style applied while the column is being dragged. |
Header
Gets or sets the content of the column header.
Declaration
public object Header { get; set; }
Property Value
Type | Description |
---|---|
System. |
The column header content. The default is null. |
HeaderStyle
Gets or sets the style that is used when rendering the column header.
Declaration
public Style HeaderStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The style that is used when rendering the column header, or null to use the Column |
IsAutoGenerated
Gets a value that indicates whether the column is auto-generated.
Declaration
public bool IsAutoGenerated { get; }
Property Value
Type | Description |
---|---|
System. |
true if the column is auto-generated; otherwise, false. |
IsFrozen
Gets a value that indicates whether the column is prevented from scrolling horizontally.
Declaration
public bool IsFrozen { get; }
Property Value
Type | Description |
---|---|
System. |
true if the column cannot be scrolled horizontally; otherwise, false. |
IsReadOnly
Gets or sets a value that indicates whether cells in the column can be edited.
Declaration
public bool IsReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if cells in the column cannot be edited; otherwise, false. The default is false. |
Exceptions
Type | Condition |
---|---|
System. |
When setting this property to false on a column derived from Data |
MaxWidth
Gets or sets the maximum column width in pixels.
Declaration
public double MaxWidth { get; set; }
Property Value
Type | Description |
---|---|
System. |
The maximum column width in pixels. The default is System. |
Exceptions
Type | Condition |
---|---|
System. |
When setting this property, the specified value is less than 0.-or-The specified value is less than the
Min |
MinWidth
Gets or sets the minimum column width in pixels.
Declaration
public double MinWidth { get; set; }
Property Value
Type | Description |
---|---|
System. |
The minimum column width in pixels, or 0 if the value is not set. The default is 0. |
Exceptions
Type | Condition |
---|---|
System. |
When setting this property, the specified value is less than 0.-or-The specified value is greater than the
Max |
System. |
The specified value is System. |
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. |
Visibility
Gets or sets the visibility of the column.
Declaration
public Visibility Visibility { get; set; }
Property Value
Type | Description |
---|---|
Visibility | An enumeration value that specifies the column visibility. The default is Visible. |
Width
Gets or sets the column width or an automatic sizing mode.
Declaration
public DataGridLength Width { get; set; }
Property Value
Type | Description |
---|---|
Data |
A structure that represents the column width or an automatic sizing mode. The default is the Column |
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 |
---|---|---|
Framework |
editingElement | The element that the column displays for a cell in editing mode. |
System. |
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 |
---|---|---|
Data |
cell | The cell that will contain the generated element. |
System. |
dataItem | The data item represented by the row that contains the intended cell. |
Returns
Type | Description |
---|---|
Framework |
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 |
---|---|---|
Data |
cell | The cell that will contain the generated element. |
System. |
dataItem | The data item represented by the row that contains the intended cell. |
Returns
Type | Description |
---|---|
Framework |
A new, read-only element that is bound to the column's Binding property value. |
GetCellContent(Object)
Gets the Content property value for the cell at the intersection of this column and the row that represents the specified data item.
Declaration
public FrameworkElement GetCellContent(object dataItem)
Parameters
Type | Name | Description |
---|---|---|
System. |
dataItem | The data item represented by the row that contains the intended cell. |
Returns
Type | Description |
---|---|
Framework |
The cell content. Returns null if the row containing dataItem is not found. |
Exceptions
Type | Condition |
---|---|
System. |
dataItem is null. |
System. |
This column has not been added to a Data |
GetCellContent(DataGridRow)
Gets the Content property value for the cell at the intersection of this column and the specified row.
Declaration
public FrameworkElement GetCellContent(DataGridRow dataGridRow)
Parameters
Type | Name | Description |
---|---|---|
Data |
dataGridRow | The row that contains the intended cell. |
Returns
Type | Description |
---|---|
Framework |
The cell content. |
Exceptions
Type | Condition |
---|---|
System. |
dataGridRow is null. |
System. |
This column has not been added to a Data |
GetColumnContainingElement(FrameworkElement)
Returns the column which contains the given element
Declaration
public static DataGridColumn GetColumnContainingElement(FrameworkElement element)
Parameters
Type | Name | Description |
---|---|---|
Framework |
element | element contained in a column |
Returns
Type | Description |
---|---|
Data |
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. |
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 |
---|---|---|
Framework |
editingElement | The element that the column displays for a cell in editing mode. |
Routed |
editingEventArgs | Information about the user gesture that is causing a cell to enter editing mode. |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
Framework |
element | Indicates the element that needs to be refreshed |
System. |
propertyName | Indicates which property changed and caused this call |