Back to Devexpress

DataControlBase.ItemsSource Property

wpf-devexpress-dot-xpf-dot-grid-dot-datacontrolbase-45b0af15.md

latest8.7 KB
Original Source

DataControlBase.ItemsSource Property

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

Declaration

csharp
[Bindable(true)]
public object ItemsSource { get; set; }
vb
<Bindable(True)>
Public Property ItemsSource As Object

Property Value

TypeDescription
Object

A data source from which the grid retrieves its data.

|

Remarks

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

xml
<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

xml
<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

xml
<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

xml
</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

xml
<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

csharp
InitializeComponent();
gridControl1.ItemsSource = Staff.GetStaff1();
gridControl2.ItemsSource = Staff.GetStaff2();

wpf-pivotgrid-how-to-display-underlying-data-asynchronously/CS/WpfDrillDownDataSourceExample/MainWindow.xaml.cs#L32

csharp
}
    gridControl1.ItemsSource = OrderDrillDownList;
}

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/MainWindow.xaml.cs#L109

csharp
void ShowExamplesInTreeList(TreeListControl treeList1, List<CodeExampleGroup> examples) {
    treeList1.ItemsSource = examples;
}

wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/MainWindow.xaml.cs#L121

csharp
{
    treeList1.ItemsSource = examples;
}

wpf-richedit-document-api/CS/DXRichEditControlAPISample/MainWindow.xaml.cs#L87

csharp
void ShowExamplesInTreeList(TreeListControl treeList1, List<CodeExampleGroup> examples) {
    treeList1.ItemsSource = examples;
}

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/MainWindow.xaml.vb#L117

vb
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

vb
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

vb
Private Sub ShowExamplesInTreeList(ByVal treeList1 As TreeListControl, ByVal examples As List(Of CodeExampleGroup))
    treeList1.ItemsSource = examples
End Sub

wpf-spreadsheet-bind-grid-control-to-worksheet-data/VB/WpfSpreadsheet_DataBinding/MainWindow.xaml.vb#L30

vb
' 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

vb
InitializeComponent()
    Me.dxGrid.ItemsSource = Me.Tasks
End Sub

See Also

RestoreStateOnSourceChange

DataControlBase Class

DataControlBase Members

DevExpress.Xpf.Grid Namespace