Warung Bebas

Minggu, 08 Mei 2011

New features for data bindings

In the last week bindings got a lot new features:

Property path:
That means if you want to bind for example MainForm.Font.Size to your control you easily specify it by setting the MainForm as Source and Font.Size as SourcePropertyName.
You could do that before already but you had to bind to MainForm.Font as Source and Size as SourcePropertyName. But that was not possible in the IDE because of the limitation of the property editor for the source property. It is on the todo list to support nested object properties for the source property in the IDE also.

Collections:
Bindings now support collections. More exactly, descendants of TEnumerable<TObject> that implement INotifyCollectionChanged. There is a new base class called TObservableCollection<T> which inherits from TObjectList<T>. I added one control so far that supports this: TListBox.
There is a new sample that shows how to display a list of data objects in the listbox and how to bind other controls to edit the selected item.
Since that feature is still under development you might notice some problems with it especially not updating listbox when selected item has been edited. Also when creating and freeing objects in the FormCreate and FormDestroy that are referenced by design time defined bindings you might experience some problems. Make sure you handle those objects in the constructor (before inherited) and destructor (after inherited) for the bindings to recognize them correctly.

Data templates:
This piece came from another project (which I will let you know about shortly) but made perfect sense for the collection support. When you add a list of objects to some control. How should the control know what data to display? This is what data templates are for. You specify what class the template is for and what data is displayed. If you look at the code you might recognize where they originally came from.

0 komentar em “New features for data bindings”

Posting Komentar

 

Indah Hidup Copyright © 2012 Fast Loading -- Powered by Blogger