Back to Devexpress

WPF Data Grid: Bind to Data

wpf-7352-controls-and-libraries-data-grid-bind-to-data.md

latest7.4 KB
Original Source

WPF Data Grid: Bind to Data

  • Jun 08, 2025
  • 4 minutes to read

Data Binding Basics

Do the following to bind the Grid to data:

  1. Use the ItemsSource property to bind the GridControl to data.
  2. Manually create columns in XAML and use the FieldName and Binding properties to bind the columns to data.

Implement CRUD Operations

To post user changes to the data source, implement CRUD operations (create, read, update, delete). Refer to the following topic for more information: CRUD Operations in a Data-Bound Grid.

MVVM Specifics

The MVVM Support section describes how to bind the Data Grid to a view model.

Items Source Wizard

You can use the Items Source Wizard to bind the Grid to data. This wizard generates the data binding and CRUD code in XAML and code-behind.

The Items Source Wizard does not support ICollectionView and Microsoft Excel data sources.

Common Data Binding Scenarios

The following topics describe how to bind the WPF Data Grid to specific data sources:

Large and Unknown Size Datasets

Server Mode and Instant Feedback Mode

The Data Grid includes Server Mode and Instant Feedback Mode designed specifically for large data sources.

The following data sources support Server Mode and Instant Feedback Mode:

|

Data Access Technology

|

Server Mode Data Source

|

Instant Feedback UI Data Source

| | --- | --- | --- | |

Entity Framework 4+

|

EntityServerModeSource

|

EntityInstantFeedbackSource

| |

eXpress Persistent Objects

|

XPServerCollectionSource

|

XPInstantFeedbackSource

| |

OData v4

|

ODataServerModeSource

|

ODataInstantFeedbackSource

| |

WCF Data Services

|

WcfServerModeSource

|

WcfInstantFeedbackSource

| |

LINQ to SQL

|

LinqServerModeSource

|

LinqInstantFeedbackSource

| |

Parallel LINQ to Objects

|

PLinqServerModeSource

|

PLinqInstantFeedbackSource

|

Refer to the following topic for more information: Server Data and Large Data Sources.

A 1-Click Solution for CRUD Web API Services with Role-based Access Control via EF Core & XPO

If you target .NET for your backend API, be sure to check out our free Web API Service and register your FREE copy today. The Solution Wizard scaffolds an OData v4 Web API Service (.NET 6+) with integrated authorization & CRUD operations powered by EF Core and our XPO ORM library. You can use OAuth2, JWT or custom authentication strategies alongside tools like Postman or Swagger (OpenAPI) for API testing. Among its numerous capabilities, our built-in Web API Service filters out secured server data based on permissions granted to users. Advanced/enterprise functions include audit trail, endpoints to download reports, file attachments, check validation, obtain localized captions, etc. To use the free Solution Wizard (which creates the Web API Service) run the Universal Component Installer from the DevExpress Download Manager.

Virtual Sources

You can use Virtual Sources to implement server-side processing for the Data Grid.

Virtual sources are compatible with any data source that exposes an API to fetch portions of data consecutively. Supported data sources include REST Services, NoSQL Databases, Custom WCF Services, EntityFramework, or any other ORM. Virtual sources do not require a total item count, and sorting, filtering, and summary calculation operations are optional.

The following tutorial describes how to use the Items Source Wizard to implement a virtual source: Bind the WPF Data Grid to Virtual Sources.

Frequently Updated Sources

If you need to implement a responsive user interface that is refreshed with real-time data, use the RealTimeSource component.

Run Demo: Real-Time Data Processing

Custom (Unstructured) Data

The UnboundDataSource component is designed for binding scenarios when no strongly typed data set is available at compile time.

Dynamic Data

The GridControl supports a variety of techniques to bind to data that changes its structure at runtime. Refer to the following example for more information:

View Example: Bind GridControl to Dynamic Data

Example

The following example illustrates how to bind the WPF Data Grid to different data source types:

View Example: Bind the WPF Data Grid to Data

This example includes multiple solutions that demonstrate:

  • How to bind the Data Grid to Entity Framework, Entity Framework Core, and XPO.
  • Different binding mechanisms: virtual sources, server mode sources, and local data.
  • MVVM and code-behind patterns.

View Example: Use UnboundDataSource to Populate WPF Data Grid with Data

View Example: WPF Blank App with the Northwind Database