Gets a collection that contains all the columns in the DataGrid. The collection of columns in the DataGrid. The following example shows how to set properties on columns in the collection when they are auto-generated and when an event occurs. Use the Columns collection to add columns, remove columns, or update properties on the columns. The order of columns in the collection does not determine the order that they will appear in the DataGrid. The DisplayIndex property determines the column order.
Each column in the Columns collection defines a column in the DataGrid. The following table lists the four column types that the DataGrid provides. In addition, you can define your own custom column by using DataGridTemplateColumn. Columns in the collection must derive from DataGridColumn. Raises the ColumnHeaderDragDelta event. Raises the ColumnHeaderDragStarted event. Raises the ColumnReordered event. Raises the ColumnReordering event. Invoked whenever an unhandled ContextMenuClosing routed event reaches this class in its route.
Implement this method to add class handling for this event. Raises the CopyingRowClipboardContent event. Returns the automation peer for this DataGrid. Raises the CurrentCellChanged event. Invoked when the DisplayMemberPath property changes. Invoked when an unhandled DragEnter attached event reaches an element in its route that is derived from this class. Invoked when an unhandled DragLeave attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled DragOver attached event reaches an element in its route that is derived from this class. Provides handling for the Executed event associated with the BeginEditCommand command. Provides handling for the Executed event associated with the CancelEditCommand command. Provides handling for the Executed event associated with the CommitEditCommand command. Provides handling for the Executed event associated with the Copy command.
Provides handling for the Executed event associated with the DeleteCommand command. Invoked when an unhandled GiveFeedback attached event reaches an element in its route that is derived from this class. Invoked whenever an unhandled GotFocus event reaches this element in its route. Invoked when an unhandled GotKeyboardFocus attached event reaches an element in its route that is derived from this class. Invoked when an unhandled GotMouseCapture attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled GotStylusCapture attached event reaches an element in its route that is derived from this class. Provides class handling for the GotTouchCapture routed event that occurs when a touch is captured to this element. Invoked when the GroupStyleSelector property changes. Raises the Initialized event. This method is invoked whenever IsInitialized is set to true internally.
Raises the InitializingNewItem event. Invoked when an unhandled IsKeyboardFocusedChanged event is raised on this element. Called when the IsKeyboardFocusWithin property has changed. Called when the IsMouseCaptured property changes on this element.
Invoked when an unhandled IsStylusCapturedChanged event is raised on this element. Invoked when the ItemBindingGroup property changes. Invoked when the ItemContainerStyle property changes.
Invoked when the ItemContainerStyleSelector property changes. Invoked when the ItemsPanel property changes. Invoked when the ItemsSource property changes. Invoked when the ItemStringFormat property changes. Invoked when the ItemTemplate property changes.
Invoked when the ItemTemplateSelector property changes. Invoked when the KeyDown event is received. Invoked when an unhandled KeyUp attached event reaches an element in its route that is derived from this class.
Raises the LoadingRow event. Raises the LoadingRowDetails event. Raises the LostFocus routed event by using the event data that is provided. Invoked when an unhandled LostKeyboardFocus attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled LostMouseCapture attached event reaches an element in its route that is derived from this class. Invoked when an unhandled LostStylusCapture attached event reaches an element in its route that is derived from this class.
Provides class handling for the LostTouchCapture routed event that occurs when this element loses a touch capture. Called when the ManipulationBoundaryFeedback event occurs. Called when the ManipulationCompleted event occurs.
Called when the ManipulationDelta event occurs. Called when the ManipulationInertiaStarting event occurs. Called when the ManipulationStarted event occurs. Provides class handling for the ManipulationStarting routed event that occurs when the manipulation processor is first created. Raises the MouseDoubleClick routed event.
Invoked when an unhandled MouseDown attached event reaches an element in its route that is derived from this class. Invoked when an unhandled MouseEnter attached event is raised on this element. Invoked when an unhandled MouseLeave attached event is raised on this element.
Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element. Invoked when an unhandled MouseLeftButtonUp routed event reaches an element in its route that is derived from this class. Updates the collection of items that are selected due to the user dragging the mouse in the DataGrid.
Invoked when an unhandled MouseRightButtonDown routed event reaches an element in its route that is derived from this class. Invoked when an unhandled MouseRightButtonUp routed event reaches an element in its route that is derived from this class.
Invoked when an unhandled MouseUp routed event reaches an element in its route that is derived from this class. Invoked when an unhandled MouseWheel attached event reaches an element in its route that is derived from this class. Raises the PreparingCellForEdit event. Invoked when an unhandled PreviewDragEnter attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewDragLeave attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewDragOver attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewDrop attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewGiveFeedback attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewGotKeyboardFocus attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewKeyDown attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewKeyUp attached event reaches an element in its route that is derived from this class.
Raises the PreviewMouseDoubleClick routed event. Invoked when an unhandled PreviewMouseDown attached routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseLeftButtonDown routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseLeftButtonUp routed event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewMouseMove attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseRightButtonDown routed event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseRightButtonUp routed event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewMouseUp attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewMouseWheel attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewQueryContinueDrag attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusButtonDown attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusButtonUp attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusDown attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewStylusInAirMove attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusInRange attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusMove attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusOutOfRange attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled PreviewStylusSystemGesture attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewStylusUp attached event reaches an element in its route that is derived from this class. Invoked when an unhandled PreviewTextInput attached event reaches an element in its route that is derived from this class. Provides class handling for the PreviewTouchDown routed event that occurs when a touch presses this element.
Provides class handling for the PreviewTouchMove routed event that occurs when a touch moves while inside this element. Provides class handling for the PreviewTouchUp routed event that occurs when a touch is released inside this element. Invoked whenever the effective value of any dependency property on this FrameworkElement has been updated.
The specific dependency property that changed is reported in the arguments parameter. Invoked when an unhandled QueryContinueDrag attached event reaches an element in its route that is derived from this class. Invoked when an unhandled QueryCursor attached event reaches an element in its route that is derived from this class.
When overridden in a derived class, participates in rendering operations that are directed by the layout system. The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
Raises the SizeChanged event, using the specified information as part of the eventual event data. Raises the RowDetailsVisibilityChanged event. Raises the RowEditEnding event. Raises the SelectedCellsChanged event. Raises the Sorting event. Invoked when an unhandled StylusButtonDown attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusButtonUp attached event reaches an element in its route that is derived from this class.
Invoked when an unhandled StylusDown attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusEnter attached event is raised by this element. Invoked when an unhandled StylusInAirMove attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusInRange attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusLeave attached event is raised by this element.
Invoked when an unhandled StylusMove attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusOutOfRange attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusSystemGesture attached event reaches an element in its route that is derived from this class. Invoked when an unhandled StylusUp attached event reaches an element in its route that is derived from this class.
Called whenever the template of the DataGrid changes. Provides class handling for the TextInput routed event. Invoked when the TextInput event is received. Invoked whenever an unhandled ToolTipClosing routed event reaches this class in its route. Invoked whenever the ToolTipOpening routed event reaches this class in its route. Provides class handling for the TouchDown routed event that occurs when a touch presses inside this element.
Provides class handling for the TouchEnter routed event that occurs when a touch moves from outside to inside the bounds of this element. Provides class handling for the TouchLeave routed event that occurs when a touch moves from inside to outside the bounds of this UIElement. Provides class handling for the TouchMove routed event that occurs when a touch moves while inside this element.
Provides class handling for the TouchUp routed event that occurs when a touch is released inside this element. Raises the UnloadingRow event. Raises the UnloadingRowDetails event. Called when the VisualCollection of the visual object is modified. Invoked when the parent of this element in the visual tree is changed. Supports incremental layout implementations in specialized subclasses of FrameworkElement.
ParentLayoutInvalidated UIElement is invoked when a child element has invalidated a property that is marked in metadata as affecting the parent's measure or arrange passes during layout. Converts a Point in screen coordinates into a Point that represents the current coordinate system of the Visual. Converts a Point that represents the current coordinate system of the Visual into a Point in screen coordinates. Determines the next element that would receive focus relative to this element for a provided focus movement direction, but does not actually move the focus.
Raises a specific routed event. The RoutedEvent to be raised is identified within the RoutedEventArgs instance that is provided as the RoutedEvent property of that event data. Provides an accessor that simplifies access to the NameScope registration method. Removes the provided object from this element's logical tree.
FrameworkElement updates the affected logical tree parent pointers to keep in sync with this deletion. Scrolls the DataGrid vertically to display the row for the specified data item. Scrolls the DataGrid vertically and horizontally to display a cell for the specified data item and column. Selects all of the items in the MultiSelector.
Selects all the cells in the DataGrid. Attaches a binding to this element, based on the provided source property name as a path qualification to the data source. Sets the value of the DetailsVisibility property for the DataGridRow that contains the specified object.
Searches for a resource with the specified name and sets up a resource reference to it for the specified property. Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.
Returns a value that indicates whether to apply the style from the ItemContainerStyle or ItemContainerStyleSelector property to the container element of the specified item. Returns whether serialization processes should serialize the contents of the CommandBindings property on instances of this class. Returns a value that indicates whether serialization processes should serialize the effective value of the GroupStyle property.
Returns whether serialization processes should serialize the contents of the InputBindings property on instances of this class. Returns a value that indicates whether serialization processes should serialize the effective value of the Items property. Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property. Returns whether serialization processes should serialize the contents of the Resources property.
Returns whether serialization processes should serialize the contents of the Style property. Returns whether serialization processes should serialize the contents of the Triggers property. Provides a string representation of the ItemsControl object. Returns a transform that can be used to transform coordinates from the Visual to the specified Visual ancestor of the visual object.
Returns a transform that can be used to transform coordinates from the Visual to the specified Visual3D ancestor of the visual object. Returns a transform that can be used to transform coordinates from the Visual to the specified visual object descendant. Returns a transform that can be used to transform coordinates from the Visual to the specified visual object. Translates a point relative to this element to coordinates that are relative to the specified element.
Simplifies access to the NameScope de-registration method. Unselects all of the items in the MultiSelector.
Unselects all the cells in the DataGrid. Reapplies the default style to the current FrameworkElement. Enforces that the calling thread has access to this DispatcherObject. Occurs before a new item is added to the DataGrid.
Occurs when the DisplayIndex property on one of the columns changes. Occurs when the value of the CurrentCell property has changed. Occurs when the input system reports an underlying drag event with this element as the drag target. Occurs when the input system reports an underlying drag event with this element as the drag origin. Occurs when the input system reports an underlying drag event with this element as the potential drop target.
Occurs when the input system reports an underlying drop event with this element as the drop target. Occurs when the value of the Focusable property changes. Occurs when the input system reports an underlying drag-and-drop event that involves this element. Occurs when this FrameworkElement is initialized.
This event coincides with cases where the value of the IsInitialized property changes from false or undefined to true. Occurs when the value of the IsEnabled property on this element changes. Occurs when the value of the IsHitTestVisible dependency property changes on this element. Occurs when the value of the IsKeyboardFocused property changes on this element.
Occurs when the value of the IsKeyboardFocusWithin property changes on this element. Occurs when the value of the IsMouseCaptured property changes on this element. Occurs when the value of the IsMouseDirectlyOver property changes on this element. Occurs when the value of the IsStylusCaptured property changes on this element. Occurs when the value of the IsStylusCaptureWithin property changes on this element. Occurs when the value of the IsStylusDirectlyOver property changes on this element.
Occurs when the value of the IsVisible property changes on this element. Occurs when the layout of the various visual elements associated with the current Dispatcher changes.
Occurs after a DataGridRow is instantiated, so that you can customize it before it is used. Occurs when a manipulation and inertia on the UIElement object is complete. Occurs when the input device loses contact with the UIElement object during a manipulation and inertia begins.
Occurs when an input device begins a manipulation on the UIElement object. Occurs when there is a change in the keyboard or mouse button state during a drag-and-drop operation. Occurs when the stylus moves while over the element. The stylus must move while being detected by the digitizer to raise this event, otherwise, PreviewStylusInAirMove is raised instead.
Occurs when the cursor is requested to display. This event is raised on an element each time that the mouse pointer moves to a new location, which means the cursor object might need to be changed based on its new position. Occurs when BringIntoView Rect is called on this element.
Occurs when the SelectedCells collection changes. Occurs when the selection of a Selector changes. Occurs when either the ActualHeight or the ActualWidth properties change value on this element. Occurs when the stylus moves over this element. The stylus must move while on the digitizer to raise this event. Otherwise, StylusInAirMove is raised instead. Occurs when a DataGridRow object becomes available for reuse. This member supports the Windows Presentation Foundation WPF infrastructure and is not intended to be used directly from your code.
Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Data Grid Class Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback? Namespace: System.
Controls Assembly: PresentationFramework. Represents a control that displays data in a customizable grid. Note Whether editing actions are allowed is influenced by a variety of additional factors, including the IsReadOnly and IsEnabled state of the DataGrid , and whether the underlying data collection allows the action. Note Setting a visual property only has an effect if that property is both present in the control's default template and is set by using a TemplateBinding.
In this article. Set the SelectionMode and SelectionUnit properties. Check the SelectedCells property to get the selected cells and check the SelectedItems property to get the selected rows. For more information, see the SelectedCells property. Handle the AutoGeneratingColumn event. Set the FrozenColumnCount property to 1 and move the column to the left-most position by setting the DisplayIndex property to 0. Create each column in the DataGrid.
Bind each column by setting the XPath on the binding to the query that gets the property on the item source. For an example, see DataGridTextColumn. Define a RowDetailsTemplate to specify the appearance of the details section. Set the RowDetailsVisibilityMode to specify when the details section is shown. Gets the rendered height of this element. Inherited from FrameworkElement. Gets the rendered width of this element. Inherited from UIElement. Inherited from ItemsControl.
Gets a value that indicates whether at least one touch is captured to this element. Gets a value that indicates whether at least one touch is pressed over this element. Gets or sets a value that indicates whether the row details can scroll horizontally. Gets or sets a value that indicates whether the columns are created automatically. Gets or sets a brush that describes the background of a control. Inherited from Control. Gets or sets a brush that describes the border background of a control.
Gets or sets the border thickness of a control. Inherited from MultiSelector. Gets or sets a value that indicates how content is copied to the clipboard.
Gets or sets the cursor that displays when the mouse pointer is over this element. Gets or sets the data context for an element when it participates in data binding. Represents the command that indicates the intention to delete the current row. Inherited from DependencyObject. Gets the size that this element computed during the measure pass of the layout process. Inherited from DispatcherObject. Gets or sets a value that indicates whether column virtualization is enabled.
Gets or sets a value that indicates whether row virtualization is enabled. Gets the key that references the default border brush for a focused cell.
Primitives; using System. AsDataView ; this. Monday, August 6, AM. Tuesday, August 7, AM. It seems that if the DataGrid has no content then the scrollbars are not shown. Lloyd Sheen. Monday, August 6, PM. Hi SanthoshDevi, Yes, you can add least one row and the horizontal scroll bar will display.
I don't have data Thank you Devi.
0コメント