[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Collapse]Build an Application
  [Expand]Choose Application UI
  [Expand]Printing and Exporting
  [Collapse]WinForms MVVM
   [Expand]Design-time Support
     Lesson 1 - Creating The Project. Scaffolding Wizard.
     Lesson 2 - Creating Views
     Lesson 3 - Navigation and Services
     Lesson 4 - Data Binding
     Lesson 5 - Login Form
     Lesson 6 - Lookup Editors and Master Detail
     Lesson 7 - Additional Functionality
  [Expand]Right-to-Left Layout
   Redistribution and Deployment
   How to: Perform Actions On Application Startup
 [Expand]Controls and Libraries
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Lesson 6 - Lookup Editors and Master Detail

This lesson describes how to populate drop-down menus of lookup editors with specific data field records. The second section describes the similar approach used to implement a more complex task - running detail View grids in Master-Detail mode.

Expanded Editor Drop-Downs

In Lesson 4, you used MvvmContext's API to bind grid controls and editors to specific data fields. Editors in the TransactionEditFormView have drop-downs that should be populated with records of existing accounts and categories. This task is accomplished by a single line of code for each editor, as shown below.

This is possible because the Scaffolding Wizard has generated two bindable properties for your TransactionViewModel:

These properties retrieve available account and category list, that can be later shown in your TransactionEditFormView. Hence, the majority of the task is already done by the Wizard. However, there can be tasks or certain scenarios, where you will have to manually implement such properties. For instance, applying Master-Detail mode to your grid controls.

Expanded Master-Detail Mode

In this Mvvm Expenses sample application, Account and Category Views display lists of available financial accounts and possible transaction categories respectively. It would be reasonable to display all transactions for each account and each existing category type.

  1. Start with adding a new GridControl to both AccountEditFormView and CategoriesEditFormView Views.

  2. There are no auto-generated properties by the Scaffolding Wizard, containing transaction lists for Account and Category ViewModels, so implement them manually as the code below illustrates.

    This code will retrieve the Entities collection records from the Transaction model that match this account's or category's ID.

  3. Now you can bind your grid controls to these bindable properties.

    Additionally, you can switch your grid controls to read-only mode and hide the 'Account' column for the AccountEditFormView and 'Category' column for the CategoriesEditFormView.

    This will make your detail Views show grid controls, running in master-detail mode. The following figure illustrates the result with the horizontal document group within the document manager's content area. The transaction list, displayed in the right group region, reveals three transactions on the salary card account. Same transactions are shown in the master-detail grid of the 'Account - Salary Card' edit View, docked to the group's left side.

Expanded See Also

Is this topic helpful?​​​​​​​