Back to Devexpress

Items Source Wizard

wpf-16553-whats-installed-items-source-wizard.md

latest3.3 KB
Original Source

Items Source Wizard

  • Jun 06, 2023
  • 2 minutes to read

You can use the Items Source Wizard to bind the GridControl to data. This wizard generates the data binding and CRUD (Create, Read, Update, Delete) code in XAML and code-behind.

The Items Source Wizard supports the MVVM pattern and can generate CRUD code to the specified ViewModel.

Data Sources

To bind to a database, create an empty ViewModel that implements ViewModelBase:

csharp
using DevExpress.Mvvm;

namespace WPFBlankAppWithDatabase {
    public class ViewModel : ViewModelBase {

    }
}
vb
Imports DevExpress.Mvvm

Namespace WPFBlankAppWithDatabase
    Public Class ViewModel
        Inherits ViewModelBase

        End Sub
    End Class
End Namespace

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

Invoke the Items Source Wizard

Open the GridControl‘s Quick Actions and select Bind to Data Source to invoke the wizard:

CRUD (Create, Read, Update, Delete) Options

The Items Source Wizard generates code that saves user-made changes back to the database. You can select which options to implement:

You can choose where to generate the code:

View Model

The code is added to the selected class that you use as the view model. If you specify a class as the DataContext in XAML, the Items Source Wizard automatically selects this class.

The selected class needs to implement the INotifyPropertyChanged interface. We recommend that you inherit your view model from the ViewModelBase class.

Code-Behind The code is added to the MainWindow.Xaml.cs/MainWindow.Xaml.vb file.

Example

The GridControl - Getting Started tutorial illustrates how to use the Items Source Wizard :

  • Lesson 1 shows how to use the wizard to bind the grid to data.
  • Lesson 3 includes details about the CRUD code generated by the wizard.

See Also

WPF Data Grid: Bind to Data

CRUD Operations in a Data-Bound Grid