wpf-devexpress-dot-xpf-dot-grid-dot-datacontrolbase-45b0af15.md
Gets or sets the grid’s data source. This is a dependency property.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
[Bindable(true)]
public object ItemsSource { get; set; }
<Bindable(True)>
Public Property ItemsSource As Object
| Type | Description |
|---|---|
| Object |
A data source from which the grid retrieves its data.
|
The grid cannot operate without a data source. It can be bound to data from a database, from an XML file, or to any data created at runtime. The grid can be bound to any object that implements the IEnumerable interface or its descendant (e.g. IList, ICollection). To bind a grid, you should assign a data source to the ItemsSource property. Note that the grid cannot be bound at design-time - only at runtime.
View Example: Bind the WPF Data Grid to Data
Tip
Topic : Binding to Data Overview
The following code snippets (auto-collected from DevExpress Examples) contain references to the ItemsSource property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
how-to-bind-wpf-grid-to-data/CS/ViewModel/EFCore/LocalData/MainWindow.xaml#L11
<Grid>
<dxg:GridControl x:Name="grid" ItemsSource="{Binding ItemsSource}">
<dxg:GridControl.View>
wpf-data-grid-implement-crud-operations/CS/ViewModel/EFCore/LocalData/MainWindow.xaml#L27
<dxg:GridControl x:Name="grid" Grid.Row="1"
ItemsSource="{Binding ItemsSource}" RestoreStateKeyFieldName="Id"
RestoreStateOnSourceChange="True">
wpf-bind-gridcontrol-to-dynamic-data/CS/VirtualSources.InfiniteAsyncSource/MainWindow.xaml#L16
<dxg:GridControl AutoGenerateColumns="AddNew">
<dxg:GridControl.ItemsSource>
<dx:InfiniteAsyncSource CustomProperties="{Binding CustomFields}" FetchRowsCommand="{Binding FetchRowsCommand}" />
wpf-data-grid-extend-crud-operations/CS/AsyncCRUDOperations/MainWindow.xaml#L20
</dxb:ToolBarControl>
<dxg:GridControl x:Name="grid" ItemsSource="{Binding ItemsSource}" RestoreStateKeyFieldName="Id" RestoreStateOnSourceChange="True" Grid.Row="1">
<dxmvvm:Interaction.Behaviors>
wpf-data-grid-process-frequent-data-updates/CS/ChunkAndOptSummariesExample/MainWindow.xaml#L16
<Grid>
<dxg:GridControl Name="grid" AutoGenerateColumns="None" AllowLiveDataShaping="True" OptimizeSummaryCalculation="True" ItemsSource="{Binding Devices}">
<dxg:GridControl.TotalSummary>
how-to-implement-drag-and-drop-between-gridcontrols-t566656/CS/MainWindow.xaml.cs#L8
InitializeComponent();
gridControl1.ItemsSource = Staff.GetStaff1();
gridControl2.ItemsSource = Staff.GetStaff2();
}
gridControl1.ItemsSource = OrderDrillDownList;
}
wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/MainWindow.xaml.cs#L109
void ShowExamplesInTreeList(TreeListControl treeList1, List<CodeExampleGroup> examples) {
treeList1.ItemsSource = examples;
}
wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/MainWindow.xaml.cs#L121
{
treeList1.ItemsSource = examples;
}
wpf-richedit-document-api/CS/DXRichEditControlAPISample/MainWindow.xaml.cs#L87
void ShowExamplesInTreeList(TreeListControl treeList1, List<CodeExampleGroup> examples) {
treeList1.ItemsSource = examples;
}
wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/MainWindow.xaml.vb#L117
Private Sub ShowExamplesInTreeList(ByVal treeList1 As TreeListControl, ByVal examples As List(Of CodeExampleGroup))
treeList1.ItemsSource = examples
End Sub
wpf-spreadsheet-pivot-table-api-examples/VB/SpreadsheetWPFPivotTableExamples/MainWindow.xaml.vb#L119
Private Sub ShowExamplesInTreeList(ByVal treeList1 As TreeListControl, ByVal examples As List(Of CodeExampleGroup))
treeList1.ItemsSource = examples
End Sub
wpf-richedit-document-api/VB/DXRichEditControlAPISample/MainWindow.xaml.vb#L100
Private Sub ShowExamplesInTreeList(ByVal treeList1 As TreeListControl, ByVal examples As List(Of CodeExampleGroup))
treeList1.ItemsSource = examples
End Sub
' Bind the grid control to the table data.
grid.ItemsSource = expensesTable.DataRange.GetDataSource(options)
' #End Region ' #BindGridToSpreadsheetTable
wpf-use-devexpress-theme-in-applications/VB/DevExpress.Examples.ThemeSwitcher/MainWindow.xaml.vb#L28
InitializeComponent()
Me.dxGrid.ItemsSource = Me.Tasks
End Sub
See Also