編集

次の方法で共有


DataGrid Class

Definition

Control to represent data in columns and rows.

[Microsoft.UI.Xaml.StyleTypedProperty(Property="CellStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.DataGridCell))]
[Microsoft.UI.Xaml.StyleTypedProperty(Property="ColumnHeaderStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridColumnHeader))]
[Microsoft.UI.Xaml.StyleTypedProperty(Property="DragIndicatorStyle", StyleTargetType=typeof(Microsoft.UI.Xaml.Controls.ContentControl))]
[Microsoft.UI.Xaml.StyleTypedProperty(Property="DropLocationIndicatorStyle", StyleTargetType=typeof(Microsoft.UI.Xaml.Controls.Control))]
[Microsoft.UI.Xaml.StyleTypedProperty(Property="RowHeaderStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridRowHeader))]
[Microsoft.UI.Xaml.StyleTypedProperty(Property="RowStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.DataGridRow))]
[Microsoft.UI.Xaml.TemplatePart(Name="RowsPresenter", Type=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridRowsPresenter))]
[Microsoft.UI.Xaml.TemplatePart(Name="ColumnHeadersPresenter", Type=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridColumnHeadersPresenter))]
[Microsoft.UI.Xaml.TemplatePart(Name="FrozenColumnScrollBarSpacer", Type=typeof(Microsoft.UI.Xaml.FrameworkElement))]
[Microsoft.UI.Xaml.TemplatePart(Name="HorizontalScrollBar", Type=typeof(Microsoft.UI.Xaml.Controls.Primitives.ScrollBar))]
[Microsoft.UI.Xaml.TemplatePart(Name="VerticalScrollBar", Type=typeof(Microsoft.UI.Xaml.Controls.Primitives.ScrollBar))]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Disabled")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Normal")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="TouchIndicator")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicator")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicatorFull")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="NoIndicator")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpanded")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsed")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpandedWithoutAnimation")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsedWithoutAnimation")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Invalid")]
[Microsoft.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Valid")]
public class DataGrid : Microsoft.UI.Xaml.Controls.Control
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="CellStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.DataGridCell))>]
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="ColumnHeaderStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridColumnHeader))>]
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="DragIndicatorStyle", StyleTargetType=typeof(Microsoft.UI.Xaml.Controls.ContentControl))>]
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="DropLocationIndicatorStyle", StyleTargetType=typeof(Microsoft.UI.Xaml.Controls.Control))>]
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="RowHeaderStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridRowHeader))>]
[<Microsoft.UI.Xaml.StyleTypedProperty(Property="RowStyle", StyleTargetType=typeof(CommunityToolkit.WinUI.UI.Controls.DataGridRow))>]
[<Microsoft.UI.Xaml.TemplatePart(Name="RowsPresenter", Type=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridRowsPresenter))>]
[<Microsoft.UI.Xaml.TemplatePart(Name="ColumnHeadersPresenter", Type=typeof(CommunityToolkit.WinUI.UI.Controls.Primitives.DataGridColumnHeadersPresenter))>]
[<Microsoft.UI.Xaml.TemplatePart(Name="FrozenColumnScrollBarSpacer", Type=typeof(Microsoft.UI.Xaml.FrameworkElement))>]
[<Microsoft.UI.Xaml.TemplatePart(Name="HorizontalScrollBar", Type=typeof(Microsoft.UI.Xaml.Controls.Primitives.ScrollBar))>]
[<Microsoft.UI.Xaml.TemplatePart(Name="VerticalScrollBar", Type=typeof(Microsoft.UI.Xaml.Controls.Primitives.ScrollBar))>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Disabled")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="CommonStates", Name="Normal")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="TouchIndicator")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicator")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="MouseIndicatorFull")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsStates", Name="NoIndicator")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpanded")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsed")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorExpandedWithoutAnimation")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ScrollBarsSeparatorStates", Name="SeparatorCollapsedWithoutAnimation")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Invalid")>]
[<Microsoft.UI.Xaml.TemplateVisualState(GroupName="ValidationStates", Name="Valid")>]
type DataGrid = class
    inherit Control
Public Class DataGrid
Inherits Control
Inheritance
Microsoft.UI.Xaml.Controls.Control
DataGrid
Attributes
Microsoft.UI.Xaml.StyleTypedPropertyAttribute Microsoft.UI.Xaml.TemplatePartAttribute Microsoft.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 (Microsoft.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.

Applies to