laitimes

DevExpress WinForm MVVM Data and Property Binding Guide (Part 2) Bindings for Nested and Non-POCO View Models for Property Data Binding

author:Huidu Technology

Depending on the properties that you bind, there are three possible scenarios:

General Binding - The viewmodel property is bound to any non-editable view element property. Because the element is not editable, you do not need to send an update notification back to the binding property (one-way binding).

Data binding - The model property (data field) is bound to the editor property. If the user can change the editor value, you need to update the binding properties (two-way binding).

Property dependency - Two properties from the same viewmodel are bound.

Devexpress universal subscription official latest version free download trial, historical version download, online documentation and help file download - Huidu.com

If you need to bind a nested viewmodel property, use the devexpress.mvvm.poco.viewmodelsource.create method to create an instance of this nested viewmodel, which you can access through the parent viewmodel, using the same setbinding method for the view binding syntax.

c #

vb.net

If you don't use the poco model, the framework doesn't automatically send update notifications. To send a notification in this case, implement the inotifypropertychanged interface or create the - propertyname-changed event. Note that you cannot use the mvvmcontext.viewmodeltype property, you should call the mvvmcontext.setviewmodel method to pass the viewmodel instance to the component.

To bind the editor to model properties, add bindsource to the view and uses the standard databindings APIs. The optional updatemode parameter allows you to specify whether the property updates its value when the editor value changes, and (if so) whether it should happen immediately or when the editor is validated.

The entity property binding demo defines a custom entity class that serves as a data record and has id and text fields. Both data fields are bound to the editor, and the bindingsource component stores the active entity object.

devexpress winform

With 180+ components and UI libraries, devexpress winform creates impactful business solutions for the Windows forms platform. Devexpress winforms is perfect for building smooth, beautiful, and easy-to-use applications, whether it's an office-style interface or analyzing and processing large amounts of business data.