DataGrid Class |
Namespace: System.Windows.Controls
public class DataGrid : MultiSelector
The DataGrid type exposes the following members.
Name | Description | |
---|---|---|
![]() | DataGrid |
Initializes a new instance of the System.Windows.Controls.DataGrid class.
|
Name | Description | |
---|---|---|
![]() | CapturePointer |
Sets pointer capture to a UIElement.
(Inherited from UIElement.) |
![]() | CreateDomChildWrapper |
When overriden, creates a dom wrapper for each child that is added to the UIElement.
(Inherited from UIElement.) |
![]() | CreateDomElement | (Inherited from Selector.) |
![]() | Equals(Object) | (Inherited from Object.) |
![]() | FindName |
Retrieves an object that has the specified identifier name.
(Inherited from FrameworkElement.) |
![]() | Focus |
Attempts to set the focus on the control.
(Inherited from Control.) |
![]() | GetChildsWrapper | (Inherited from UIElement.) |
![]() | GetDomElementWhereToPlaceChild | (Inherited from UIElement.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetValue |
Returns the current effective value of a dependency property from a DependencyObject.
(Inherited from DependencyObject.) |
![]() | INTERNAL_OnAttachedToVisualTree | (Inherited from ItemsControl.) |
![]() | INTERNAL_OnDetachedFromVisualTree | (Overrides DependencyObject.INTERNAL_OnDetachedFromVisualTree.) |
![]() | ManageIsEnabled | (Inherited from FrameworkElement.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | OnAfterApplyHorizontalAlignmentAndWidth | (Inherited from FrameworkElement.) |
![]() | OnAfterApplyVerticalAlignmentAndWidth | (Inherited from FrameworkElement.) |
![]() | OnGotFocus |
Raises the GotFocus event
(Inherited from UIElement.) |
![]() | OnItemsSourceChanged |
Raises the ItemsSourceChanged event.
(Inherited from ItemsControl.) |
![]() | OnKeyDown |
Raises the KeyDown event
(Inherited from UIElement.) |
![]() | OnKeyUp |
Raises the KeyUp event
(Inherited from UIElement.) |
![]() | OnLostFocus |
Raises the LostFocus event
(Inherited from UIElement.) |
![]() | OnPointerEntered |
Raises the PointerEntered event
(Inherited from UIElement.) |
![]() | OnPointerExited |
Raises the PointerExited event
(Inherited from UIElement.) |
![]() | OnPointerMoved | (Inherited from UIElement.) |
![]() | OnPointerPressed |
Raises the PointerPressed event
(Inherited from UIElement.) |
![]() | OnPointerReleased |
Raises the PointerReleased event
(Inherited from UIElement.) |
![]() | OnSelectionChanged |
Raises the TextChanged event
(Inherited from Selector.) |
![]() | OnTapped |
Raises the Tapped event
(Inherited from UIElement.) |
![]() | ReleasePointerCapture |
Releases pointer captures for capture of one specific pointer by this UIElement.
(Inherited from UIElement.) |
![]() | SetBinding |
Attaches a binding to a FrameworkElement, using the provided binding object.
(Inherited from DependencyObject.) |
![]() | SetInheritedValue |
Sets the inherited value of a dependency property on a DependencyObject. Do not use this method.
(Inherited from DependencyObject.) |
![]() | SetLocalValue |
Sets the local value of a dependency property on a DependencyObject while not overriding a hypothetical Binding (example: when the user writes in a TextBox with a two way Binding on its Text property).
(Inherited from DependencyObject.) |
![]() | SetValue |
Sets the local value of a dependency property on a DependencyObject.
(Inherited from DependencyObject.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | TransformToVisual |
Returns a transform object that can be used to transform coordinates from
the UIElement to the specified object.
(Inherited from UIElement.) |
Name | Description | |
---|---|---|
![]() | _renderedItemsPanelTemplate | (Inherited from ItemsControl.) |
![]() ![]() | AutoGenerateColumnsProperty |
Identifies the System.Windows.Controls.DataGrid.AutoGenerateColumns dependency
property.
|
![]() ![]() | ColumnHeaderStyleProperty |
Identifies the System.Windows.Controls.DataGrid.ColumnHeaderStyle dependency
property.
|
![]() ![]() | ColumnsProperty |
Identifies the System.Windows.Controls.DataGrid.Columns dependency property. |
![]() ![]() | HorizontalGridLinesBrushProperty |
Identifies the System.Windows.Controls.DataGrid.HorizontalGridLinesBrush dependency property.
|
![]() ![]() | IsReadOnlyProperty |
Identifies the System.Windows.Controls.DataGrid.IsReadOnly dependency property.
|
![]() ![]() | RowHeaderTemplateProperty |
Identifies the System.Windows.Controls.DataGrid.RowHeaderTemplate dependency property.
|
![]() ![]() | SelectedItemBackgroundProperty |
Identifies the SelectedItemBackground dependency property.
|
![]() ![]() | SelectedItemForegroundProperty |
Identifies the SelectedItemForeground dependency property.
|
![]() ![]() | SelectionModeProperty |
Identifies the System.Windows.Controls.DataGrid.SelectionMode dependency property.
|
![]() ![]() | UnselectedItemBackgroundProperty |
Identifies the UnselectedItemBackground dependency property.
|
![]() ![]() | UnselectedItemForegroundProperty |
Identifies the UnselectedItemForeground dependency property.
|
![]() ![]() | VerticalGridLinesBrushProperty |
Identifies the System.Windows.Controls.DataGrid.VerticalGridLinesBrush dependency property.
|
Name | Description | |
---|---|---|
![]() | ActualHeight |
Gets the rendered height of a FrameworkElement. The FrameworkElement must be in the visual tree,
otherwise this property will return double.NaN.
(Inherited from FrameworkElement.) |
![]() | ActualWidth |
Gets the rendered width of a FrameworkElement. The FrameworkElement must be in the visual tree,
otherwise this property will return double.NaN.
(Inherited from FrameworkElement.) |
![]() | AutoGenerateColumns |
Gets or sets a value that indicates whether the columns are created automatically.
|
![]() | Background |
Gets or sets a brush that provides the background of the control.
(Inherited from Control.) |
![]() | BorderBrush |
Gets or sets a brush that describes the border background of a control.
(Inherited from Control.) |
![]() | BorderThickness |
Gets or sets the thickness of the border.
(Inherited from Control.) |
![]() | ColumnHeaderStyle |
Gets or sets the style applied to all column headers in the System.Windows.Controls.DataGrid.
|
![]() | Columns |
Gets a collection that contains all the columns in the System.Windows.Controls.DataGrid.
|
![]() | Cursor |
Gets or sets the cursor that displays when the mouse pointer is over this
element.
(Inherited from FrameworkElement.) |
![]() | DataContext |
Gets or sets the data context for a FrameworkElement when it participates
in data binding.
(Inherited from FrameworkElement.) |
![]() | Dispatcher |
Gets the CoreDispatcher that this object is associated with.
(Inherited from DependencyObject.) |
![]() | DisplayMemberPath |
Gets or sets a path to a value on the source object to serve as the visual
representation of the object.
(Inherited from Selector.) |
![]() | Effect | (Inherited from UIElement.) |
![]() | FontFamily |
Gets or sets the font used to display text in the control.
(Inherited from Control.) |
![]() | FontSize |
Gets or sets the size of the text in this control.
(Inherited from Control.) |
![]() | FontWeight |
Gets or sets the thickness of the specified font.
(Inherited from Control.) |
![]() | Foreground |
Gets or sets a brush that describes the foreground color.
(Inherited from Control.) |
![]() | Height |
Gets or sets the suggested height of a FrameworkElement.
(Inherited from FrameworkElement.) |
![]() | HorizontalAlignment |
Gets or sets the horizontal alignment characteristics that are applied to
a FrameworkElement when it is composed in a layout parent, such as a panel
or items control.
(Inherited from FrameworkElement.) |
![]() | IsEnabled |
Gets or sets a value indicating whether the user can interact with the control.
(Inherited from FrameworkElement.) |
![]() | IsHitTestVisible |
Gets or sets whether the contained area of this UIElement can return true
values for hit testing.
(Inherited from FrameworkElement.) |
![]() | IsReadOnly |
Gets or sets a value that indicates whether the user can edit values in the
System.Windows.Controls.DataGrid.
|
![]() | Items |
Gets the collection used to generate the content of the control. WARNING: When ItemsSource is set, it will only returns a snapshot. The returned values will not be updated at the same time as the ItemsSource.
(Inherited from ItemsControl.) |
![]() | ItemsPanel |
Gets or sets the template that defines the panel that controls the layout
of items.
(Inherited from ItemsControl.) |
![]() | ItemsSource |
Gets or sets an object source used to generate the content of the ItemsControl.
(Inherited from ItemsControl.) |
![]() | ItemTemplate |
Gets or sets the DataTemplate used to display each item.
(Inherited from ItemsControl.) |
![]() | Margin |
Gets or sets the outer margin of a FrameworkElement.
(Inherited from FrameworkElement.) |
![]() | Name |
Gets or sets the identifying name of the object. When a XAML processor creates
the object tree from XAML markup, run-time code can refer to the XAML-declared
object by this name.
(Inherited from FrameworkElement.) |
![]() | Opacity |
Gets or sets the degree of the object's opacity.
A value between 0 and 1.0 that declares the opacity factor, with 1.0 meaning
full opacity and 0 meaning transparent. The default value is 1.0.
(Inherited from UIElement.) |
![]() | Padding |
Gets or sets the distance between the border and its child object.
(Inherited from Control.) |
![]() | RenderTransform |
Gets or sets transform information that affects the rendering position of
a UIElement.
(Inherited from UIElement.) |
![]() | RenderTransformOrigin | (Inherited from UIElement.) |
![]() | Resources |
Gets the locally defined resource dictionary. In XAML, you can establish
resource items as child object elements of a frameworkElement.Resources property
element, through XAML implicit collection syntax.
(Inherited from FrameworkElement.) |
![]() | RowHeaderTemplate |
Gets or set the template for the row headers.
|
![]() | SelectedIndex |
Gets or sets the index of the selected item.
(Inherited from Selector.) |
![]() | SelectedItem |
Gets or sets the selected item.
(Inherited from Selector.) |
![]() | SelectedItemBackground |
Defines the brush used for the background of a selected item.
|
![]() | SelectedItemForeground |
Defines the brush used for the foreground of an item that is not selected.
|
![]() | SelectedItems |
Gets the items in the System.Windows.Controls.Primitives.MultiSelector that
are selected.
(Inherited from MultiSelector.) |
![]() | SelectedValue |
Gets or sets the value of the selected item, obtained by using the SelectedValuePath.
(Inherited from Selector.) |
![]() | SelectedValuePath |
Gets or sets the property path that is used to get the SelectedValue property
of the SelectedItem property.
(Inherited from Selector.) |
![]() | SelectionMode |
Gets or sets a value that indicates how rows and cells are selected in the
System.Windows.Controls.DataGrid.
|
![]() | Style |
Gets or sets an instance Style that is applied for this object during rendering.
(Inherited from FrameworkElement.) |
![]() | TabIndex |
Gets or sets a value that determines the order in which elements receive
focus when the user navigates through controls by pressing the Tab key.
The default value is MaxValue
(Inherited from Control.) |
![]() | Tag |
Gets or sets an arbitrary object value that can be used to store custom information
about this object.
(Inherited from FrameworkElement.) |
![]() | UnselectedItemBackground |
Defines the brush used for the background of an item that is not selected.
|
![]() | UnselectedItemForeground |
Defines the brush used for the foreground of a selected item.
|
![]() | UseLayoutRounding |
Gets or sets a value that determines whether rendering for the object and
its visual subtree should use rounding behavior that aligns rendering to
whole pixels.
(Inherited from UIElement.) |
![]() | VerticalAlignment |
Gets or sets the vertical alignment characteristics that are applied to a
FrameworkElement when it is composed in a parent object such as a panel or
items control.
(Inherited from FrameworkElement.) |
![]() | Visibility |
Gets or sets the visibility of a UIElement. A UIElement that is not visible
is not rendered and does not communicate its desired size to layout.
(Inherited from UIElement.) |
![]() | Width |
Gets or sets the width of a FrameworkElement.
(Inherited from FrameworkElement.) |
Name | Description | |
---|---|---|
![]() | GotFocus |
Occurs when the pointer device that previously initiated a Press action is
pressed, while within this element.
Note that ONLY sender's informations are currently filled (not pointer's)
(Inherited from UIElement.) |
![]() | KeyDown |
Occurs when a keyboard key is pressed while the UIElement has focus.
(Inherited from UIElement.) |
![]() | KeyUp |
Occurs when a keyboard key is released while the UIElement has focus.
(Inherited from UIElement.) |
![]() | Loaded |
Occurs when a FrameworkElement has been constructed and added to the object tree.
(Inherited from FrameworkElement.) |
![]() | LostFocus |
Occurs when a UIElement loses focus.
(Inherited from UIElement.) |
![]() | PointerEntered |
Occurs when a pointer enters the hit test area of this element.
(Inherited from UIElement.) |
![]() | PointerExited |
Occurs when a pointer leaves the hit test area of this element.
(Inherited from UIElement.) |
![]() | PointerMoved |
Occurs when the pointer device that previously initiated a Press action is
moved, while within this element.
(Inherited from UIElement.) |
![]() | PointerPressed |
Occurs when the pointer device that previously initiated a Press action is
pressed, while within this element.
(Inherited from UIElement.) |
![]() | PointerReleased |
Occurs when the pointer device that previously initiated a Press action is
released, while within this element.
(Inherited from UIElement.) |
![]() | SelectionChanged |
Occurs when the selection is changed.
(Inherited from Selector.) |
![]() | Tapped |
Occurs when an otherwise unhandled Tap interaction occurs over the hit test
area of this element.
(Inherited from UIElement.) |
![]() | Unloaded |
Occurs when this object is no longer connected to the main object tree.
(Inherited from FrameworkElement.) |
DataGrid1.ItemsSource = Planet.GetListOfPlanets(); public class Planet { public string Name { get; set; } public string ImagePath { get; set; } public static ObservableCollection<Planet> GetListOfPlanets() { return new ObservableCollection<Planet>() { new Planet() { Name = "Mercury", ImagePath = "ms-appx:/Planets/Mercury.png" }, new Planet() { Name = "Venus", ImagePath = "ms-appx:/Planets/Venus.png" }, new Planet() { Name = "Earth", ImagePath = "ms-appx:/Planets/Earth.png" }, new Planet() { Name = "Mars", ImagePath = "ms-appx:/Planets/Mars.png" }, new Planet() { Name = "Jupiter", ImagePath = "ms-appx:/Planets/Jupiter.png" }, new Planet() { Name = "Saturn", ImagePath = "ms-appx:/Planets/Saturn.png" }, new Planet() { Name = "Uranus", ImagePath = "ms-appx:/Planets/Uranus.png" }, new Planet() { Name = "Neptune", ImagePath = "ms-appx:/Planets/Neptune.png" } new Planet() { Name = "Pluto", ImagePath = "ms-appx:/Planets/Pluto.png" } }; } }
<DataGrid x:Name="DataGrid1" Margin="0,10,0,0" AutoGenerateColumns="True" IsReadOnly="True" HorizontalGridLinesBrush="Gray" VerticalGridLinesBrush="Gray" HorizontalAlignment="Left" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><DataGrid.ColumnHeaderStyle><Style TargetType="DataGridColumnHeader"><Setter Property="Background" Value="Gray" /><Setter Property="Foreground" Value="White" /></Style></DataGrid.ColumnHeaderStyle></DataGrid>