Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Items Source Wizard

  • 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:

using DevExpress.Mvvm;

namespace WPFBlankAppWithDatabase {
    public class ViewModel : ViewModelBase {

    }
}

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:

Items Source 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:

Items Source Wizard - Settings

You can choose where to generate the code:

Items Source Wizard - Boilerplate 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