DataGrid Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Control to represent data in columns and rows.
[Windows.UI.Xaml.StyleTypedProperty(Property="CellStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.DataGridCell))]
[Windows.UI.Xaml.StyleTypedProperty(Property="ColumnHeaderStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridColumnHeader))]
[Windows.UI.Xaml.StyleTypedProperty(Property="DragIndicatorStyle", StyleTargetType=typeof(Windows.UI.Xaml.Controls.ContentControl))]
[Windows.UI.Xaml.StyleTypedProperty(Property="DropLocationIndicatorStyle", StyleTargetType=typeof(Windows.UI.Xaml.Controls.Control))]
[Windows.UI.Xaml.StyleTypedProperty(Property="RowHeaderStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridRowHeader))]
[Windows.UI.Xaml.StyleTypedProperty(Property="RowStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.DataGridRow))]
[Windows.UI.Xaml.TemplatePart(Name="RowsPresenter", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridRowsPresenter))]
[Windows.UI.Xaml.TemplatePart(Name="ColumnHeadersPresenter", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridColumnHeadersPresenter))]
[Windows.UI.Xaml.TemplatePart(Name="FrozenColumnScrollBarSpacer", Type=typeof(Windows.UI.Xaml.FrameworkElement))]
[Windows.UI.Xaml.TemplatePart(Name="HorizontalScrollBar", Type=typeof(Windows.UI.Xaml.Controls.Primitives.ScrollBar))]
[Windows.UI.Xaml.TemplatePart(Name="VerticalScrollBar", Type=typeof(Windows.UI.Xaml.Controls.Primitives.ScrollBar))]
[Windows.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Disabled")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Normal")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="TouchIndicator")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicator")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicatorFull")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="NoIndicator")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpanded")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsed")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpandedWithoutAnimation")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsedWithoutAnimation")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Invalid")]
[Windows.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Valid")]
public class DataGrid : Windows.UI.Xaml.Controls.Control
[<Windows.UI.Xaml.StyleTypedProperty(Property="CellStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.DataGridCell))>]
[<Windows.UI.Xaml.StyleTypedProperty(Property="ColumnHeaderStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridColumnHeader))>]
[<Windows.UI.Xaml.StyleTypedProperty(Property="DragIndicatorStyle", StyleTargetType=typeof(Windows.UI.Xaml.Controls.ContentControl))>]
[<Windows.UI.Xaml.StyleTypedProperty(Property="DropLocationIndicatorStyle", StyleTargetType=typeof(Windows.UI.Xaml.Controls.Control))>]
[<Windows.UI.Xaml.StyleTypedProperty(Property="RowHeaderStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridRowHeader))>]
[<Windows.UI.Xaml.StyleTypedProperty(Property="RowStyle", StyleTargetType=typeof(Microsoft.Toolkit.Uwp.UI.Controls.DataGridRow))>]
[<Windows.UI.Xaml.TemplatePart(Name="RowsPresenter", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridRowsPresenter))>]
[<Windows.UI.Xaml.TemplatePart(Name="ColumnHeadersPresenter", Type=typeof(Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridColumnHeadersPresenter))>]
[<Windows.UI.Xaml.TemplatePart(Name="FrozenColumnScrollBarSpacer", Type=typeof(Windows.UI.Xaml.FrameworkElement))>]
[<Windows.UI.Xaml.TemplatePart(Name="HorizontalScrollBar", Type=typeof(Windows.UI.Xaml.Controls.Primitives.ScrollBar))>]
[<Windows.UI.Xaml.TemplatePart(Name="VerticalScrollBar", Type=typeof(Windows.UI.Xaml.Controls.Primitives.ScrollBar))>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Disabled")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Normal")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="TouchIndicator")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicator")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicatorFull")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="NoIndicator")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpanded")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsed")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpandedWithoutAnimation")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsedWithoutAnimation")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Invalid")>]
[<Windows.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Valid")>]
type DataGrid = class
inherit Control
Public Class DataGrid
Inherits Control
- Inheritance
-
Windows.UI.Xaml.Controls.ControlDataGrid
- Attributes
-
Windows.UI.Xaml.StyleTypedPropertyAttribute Windows.UI.Xaml.TemplatePartAttribute Windows.UI.Xaml.TemplateVisualStateAttribute
Constructors
DataGrid() |
Initializes a new instance of the DataGrid class. |
Fields
AlternatingRowBackgroundProperty |
Identifies the AlternatingRowBackground dependency property. |
AlternatingRowForegroundProperty |
Identifies the AlternatingRowForeground dependency property. |
AreRowDetailsFrozenProperty |
Identifies the AreRowDetailsFrozen dependency property. |
AreRowGroupHeadersFrozenProperty |
Identifies the AreRowDetailsFrozen dependency property. |
AutoGenerateColumnsProperty |
Identifies the AutoGenerateColumns dependency property. |
CanUserReorderColumnsProperty |
Identifies the CanUserReorderColumns dependency property. |
CanUserResizeColumnsProperty |
Identifies the CanUserResizeColumns dependency property. |
CanUserSortColumnsProperty |
Identifies the CanUserSortColumns dependency property. |
CellStyleProperty |
Identifies the CellStyle dependency property. |
ClipboardCopyModeProperty |
Identifies the ClipboardCopyMode dependency property. |
ColumnHeaderHeightProperty |
Identifies the ColumnHeaderHeight dependency property. |
ColumnHeaderStyleProperty |
Identifies the ColumnHeaderStyle dependency property. |
ColumnWidthProperty |
Identifies the ColumnWidth dependency property. |
DataFetchSizeProperty |
Identifies the DataFetchSize dependency property |
DragIndicatorStyleProperty |
Identifies the DragIndicatorStyle dependency property. |
DropLocationIndicatorStyleProperty |
Identifies the DropLocationIndicatorStyle dependency property. |
FrozenColumnCountProperty |
Identifies the FrozenColumnCount dependency property. |
GridLinesVisibilityProperty |
Identifies the GridLinesVisibility dependency property. |
HeadersVisibilityProperty |
Identifies the HeadersVisibility dependency property. |
HorizontalGridLinesBrushProperty |
Identifies the HorizontalGridLinesBrush dependency property. |
HorizontalScrollBarVisibilityProperty |
Identifies the HorizontalScrollBarVisibility dependency property. |
IncrementalLoadingThresholdProperty |
Identifies the IncrementalLoadingThreshold dependency property |
IncrementalLoadingTriggerProperty |
Identifies the IncrementalLoadingTrigger dependency property |
IsReadOnlyProperty |
Identifies the IsReadOnly dependency property. |
IsValidProperty |
Identifies the IsValid dependency property. |
ItemsSourceProperty |
Identifies the ItemsSource dependency property. |
MaxColumnWidthProperty |
Identifies the MaxColumnWidth dependency property. |
MinColumnWidthProperty |
Identifies the MinColumnWidth dependency property. |
RowBackgroundProperty |
Identifies the RowBackground dependency property. |
RowDetailsTemplateProperty |
Identifies the RowDetailsTemplate dependency property. |
RowDetailsVisibilityModeProperty |
Identifies the RowDetailsVisibilityMode dependency property. |
RowForegroundProperty |
Identifies the RowForeground dependency property. |
RowHeaderStyleProperty |
Identifies the RowHeaderStyle dependency property. |
RowHeaderWidthProperty |
Identifies the RowHeaderWidth dependency property. |
RowHeightProperty |
Identifies the RowHeight dependency property. |
RowStyleProperty |
Identifies the RowStyle dependency property. |
SelectedIndexProperty |
Identifies the SelectedIndex dependency property. |
SelectedItemProperty |
Identifies the SelectedItem dependency property. |
SelectionModeProperty |
Identifies the SelectionMode dependency property. |
VerticalGridLinesBrushProperty |
Identifies the VerticalGridLinesBrush dependency property. |
VerticalScrollBarVisibilityProperty |
Identifies the VerticalScrollBarVisibility dependency property. |
Properties
AlternatingRowBackground |
Gets or sets the Brush that is used to paint the background of odd-numbered rows. |
AlternatingRowForeground |
Gets or sets the Brush that is used to paint the foreground of odd-numbered rows. |
AreRowDetailsFrozen |
Gets or sets a value indicating whether the row details sections remain fixed at the width of the display area or can scroll horizontally. |
AreRowGroupHeadersFrozen |
Gets or sets a value indicating whether the row group header sections remain fixed at the width of the display area or can scroll horizontally. |
AutoGenerateColumns |
Gets or sets a value indicating whether columns are created automatically when the ItemsSource property is set. |
CanUserReorderColumns |
Gets or sets a value indicating whether the user can change the column display order by dragging column headers with the mouse. |
CanUserResizeColumns |
Gets or sets a value indicating whether the user can adjust column widths using the mouse. |
CanUserSortColumns |
Gets or sets a value indicating whether the user can sort columns by clicking the column header. |
CellStyle |
Gets or sets the style that is used when rendering the data grid cells. |
ClipboardCopyMode |
Gets or sets the property which determines how DataGrid content is copied to the Clipboard. |
ColumnHeaderHeight |
Gets or sets the height of the column headers row. |
ColumnHeaderStyle |
Gets or sets the style that is used when rendering the column headers. |
Columns |
Gets a collection that contains all the columns in the control. |
ColumnWidth |
Gets or sets the standard width or automatic sizing mode of columns in the control. |
CurrentColumn |
Gets or sets the column that contains the current cell. |
CurrentItem |
Gets the data item bound to the row that contains the current cell. |
DataFetchSize |
Gets or sets the amount of data to fetch for virtualizing/prefetch operations. |
DragIndicatorStyle |
Gets or sets the style that is used when rendering the drag indicator that is displayed while dragging column headers. |
DropLocationIndicatorStyle |
Gets or sets the style that is used when rendering the column headers. |
FrozenColumnCount |
Gets or sets the number of columns that the user cannot scroll horizontally. |
GridLinesVisibility |
Gets or sets a value indicating which grid lines separating inner cells are shown. |
HeadersVisibility |
Gets or sets a value indicating the visibility of row and column headers. |
HorizontalGridLinesBrush |
Gets or sets the Brush that is used to paint grid lines separating rows. |
HorizontalScrollBarVisibility |
Gets or sets a value indicating how the horizontal scroll bar is displayed. |
IncrementalLoadingThreshold |
Gets or sets the threshold range that governs when the DataGrid class will begin to prefetch more items. |
IncrementalLoadingTrigger |
Gets or sets a value that indicates the conditions for prefetch operations by the DataGrid class. |
IsReadOnly |
Gets or sets a value indicating whether the user can edit the values in the control. |
IsValid |
Gets a value indicating whether data in the grid is valid. |
ItemsSource |
Gets or sets a collection that is used to generate the content of the control. |
MaxColumnWidth |
Gets or sets the maximum width of columns in the DataGrid. |
MinColumnWidth |
Gets or sets the minimum width of columns in the DataGrid. |
RowBackground |
Gets or sets the Brush that is used to paint row backgrounds. |
RowDetailsTemplate |
Gets or sets the template that is used to display the content of the details section of rows. |
RowDetailsVisibilityMode |
Gets or sets a value indicating when the details sections of rows are displayed. |
RowForeground |
Gets or sets the Brush that is used as the default cells foreground. |
RowGroupHeaderPropertyNameAlternative |
Gets or sets the label to display in a DataGridRowGroupHeader when its PropertyName is not set. |
RowGroupHeaderStyles |
Gets the style that is used when rendering the row group header. |
RowHeaderStyle |
Gets or sets the style that is used when rendering the row headers. |
RowHeaderWidth |
Gets or sets the width of the row header column. |
RowHeight |
Gets or sets the standard height of rows in the control. |
RowStyle |
Gets or sets the style that is used when rendering the rows. |
SelectedIndex |
Gets or sets the index of the current selection. |
SelectedItem |
Gets or sets the data item corresponding to the selected row. |
SelectedItems |
Gets a list that contains the data items corresponding to the selected rows. |
SelectionMode |
Gets or sets the selection behavior of the data grid. |
VerticalGridLinesBrush |
Gets or sets the Brush that is used to paint grid lines separating columns. |
VerticalScrollBarVisibility |
Gets or sets a value indicating how the vertical scroll bar is displayed. |
Methods
ArrangeOverride(Size) |
Arranges the content of the DataGridRow. |
BeginEdit() |
Enters editing mode for the current cell and current row (if they're not already in editing mode). |
BeginEdit(RoutedEventArgs) |
Enters editing mode for the current cell and current row (if they're not already in editing mode). |
CancelEdit() |
Cancels editing mode and restores the original value. |
CancelEdit(DataGridEditingUnit) |
Cancels editing mode for the specified DataGridEditingUnit and restores its original value. |
CollapseRowGroup(ICollectionViewGroup, Boolean) |
Collapses the DataGridRowGroupHeader that represents a given CollectionViewGroup |
CommitEdit() |
Commits editing mode and pushes changes to the backend. |
CommitEdit(DataGridEditingUnit, Boolean) |
Commits editing mode for the specified DataGridEditingUnit and pushes changes to the backend. |
ExpandRowGroup(ICollectionViewGroup, Boolean) |
Expands the DataGridRowGroupHeader that represents a given CollectionViewGroup |
GetGroupFromItem(Object, Int32) |
Returns the Group at the indicated level or null if the item is not in the ItemsSource |
MeasureOverride(Size) |
Measures the children of a DataGridRow to prepare for arranging them during the ArrangeOverride(Size) pass. |
OnApplyTemplate() |
Builds the visual tree for the column header when a new template is applied. |
OnAutoGeneratingColumn(DataGridAutoGeneratingColumnEventArgs) |
Raises the AutoGeneratingColumn event. |
OnBeginningEdit(DataGridBeginningEditEventArgs) |
Raises the BeginningEdit event. |
OnCellEditEnded(DataGridCellEditEndedEventArgs) |
Raises the CellEditEnded event. |
OnCellEditEnding(DataGridCellEditEndingEventArgs) |
Raises the CellEditEnding event. |
OnColumnDisplayIndexChanged(DataGridColumnEventArgs) |
OnColumnDisplayIndexChanged |
OnColumnReordered(DataGridColumnEventArgs) |
OnColumnReordered |
OnColumnReordering(DataGridColumnReorderingEventArgs) |
OnColumnReordering |
OnColumnSorting(DataGridColumnEventArgs) |
OnColumnSorting |
OnCopyingRowClipboardContent(DataGridRowClipboardEventArgs) |
This method raises the CopyingRowClipboardContent event. |
OnCreateAutomationPeer() |
Creates AutomationPeer (Windows.UI.Xaml.UIElement.OnCreateAutomationPeer) |
OnCurrentCellChanged(EventArgs) |
Raises the CurrentCellChanged event. |
OnLoadingRow(DataGridRowEventArgs) |
Raises the LoadingRow event for row preparation. |
OnLoadingRowDetails(DataGridRowDetailsEventArgs) |
Raises the LoadingRowDetails for row details preparation |
OnLoadingRowGroup(DataGridRowGroupHeaderEventArgs) |
Raises the LoadingRowGroup event |
OnPointerWheelChanged(PointerRoutedEventArgs) |
Scrolls the DataGrid according to the direction of the delta. |
OnPreparingCellForEdit(DataGridPreparingCellForEditEventArgs) |
Raises the PreparingCellForEdit event. |
OnRowDetailsVisibilityChanged(DataGridRowDetailsEventArgs) |
Raises the RowDetailsVisibilityChanged event. |
OnRowEditEnded(DataGridRowEditEndedEventArgs) |
Raises the RowEditEnded event. |
OnRowEditEnding(DataGridRowEditEndingEventArgs) |
Raises the RowEditEnding event. |
OnSelectionChanged(SelectionChangedEventArgs) |
Raises the SelectionChanged event and clears the _selectionChanged. This event won't get raised again until after _selectionChanged is set back to true. |
OnUnloadingRow(DataGridRowEventArgs) |
Raises the UnloadingRow event for row recycling. |
OnUnloadingRowDetails(DataGridRowDetailsEventArgs) |
Raises the UnloadingRowDetails event |
OnUnloadingRowGroup(DataGridRowGroupHeaderEventArgs) |
Raises the UnloadingRowGroup event |
ScrollIntoView(Object, DataGridColumn) |
Scrolls the specified item or RowGroupHeader and/or column into view. If item is not null: scrolls the row representing the item into view; If column is not null: scrolls the column into view; If both item and column are null, the method returns without scrolling. |
Events
AutoGeneratingColumn |
Occurs one time for each public, non-static property in the bound data type when the ItemsSource property is changed and the AutoGenerateColumns property is true. |
BeginningEdit |
Occurs before a cell or row enters editing mode. |
CellEditEnded |
Occurs after cell editing has ended. |
CellEditEnding |
Occurs immediately before cell editing has ended. |
ColumnDisplayIndexChanged |
Occurs when the DisplayIndex property of a column changes. |
ColumnHeaderDragCompleted |
Occurs when the user drops a column header that was being dragged using the mouse. |
ColumnHeaderDragDelta |
Occurs one or more times while the user drags a column header using the mouse. |
ColumnHeaderDragStarted |
Occurs when the user begins dragging a column header using the mouse. |
ColumnReordered |
Raised when column reordering ends, to allow subscribers to clean up. |
ColumnReordering |
Raised when starting a column reordering action. Subscribers to this event can set tooltip and caret UIElements, constrain tooltip position, indicate that a preview should be shown, or cancel reordering. |
CopyingRowClipboardContent |
This event is raised by OnCopyingRowClipboardContent method after the default row content is prepared. Event listeners can modify or add to the row clipboard content. |
CurrentCellChanged |
Occurs when a different cell becomes the current cell. |
LoadingRow |
Occurs after a DataGridRow is instantiated, so that you can customize it before it is used. |
LoadingRowDetails |
Occurs when a new row details template is applied to a row, so that you can customize the details section before it is used. |
LoadingRowGroup |
Occurs before a DataGridRowGroupHeader header is used. |
PreparingCellForEdit |
Occurs when a cell in a DataGridTemplateColumn enters editing mode. |
RowDetailsVisibilityChanged |
Occurs when the RowDetailsVisibilityMode property value changes. |
RowEditEnded |
Occurs when the row has been successfully committed or canceled. |
RowEditEnding |
Occurs immediately before the row has been successfully committed or canceled. |
SelectionChanged |
Occurs when the SelectedItem or SelectedItems property value changes. |
Sorting |
Occurs when the DataGridColumn sorting request is triggered. |
UnloadingRow |
Occurs when a DataGridRow object becomes available for reuse. |
UnloadingRowDetails |
Occurs when a row details element becomes available for reuse. |
UnloadingRowGroup |
Occurs when the DataGridRowGroupHeader is available for reuse. |