Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)
Syntax
C# |
---|
public sealed class DataObjectAccessor : DataObjectAccessorBase |
Visual Basic |
---|
Public NotInheritable Class DataObjectAccessor Inherits DataObjectAccessorBase |
Visual C++ |
---|
public ref class DataObjectAccessor sealed : public DataObjectAccessorBase |
F# |
---|
[<SealedAttribute>] type DataObjectAccessor = class inherit DataObjectAccessorBase end |
Remarks
In .Net 1.0 a very important interface was added to the System.ComponentModel namespace INotifyPropertyChanged. It is used to notify clients(typically binding clients) that a property value has changed. Wpf GridControl can bind to a data source for implementing such operations as automated real-time updates, sorting, filtering and data grouping. It's important to emphasize that all notifications are synchronized by the Wpf GridControl with GUI thread, which in turn means that data can be changed not only in GUI thread but also in any other thread, safely reporting to the Wpf GridControl about value changes.
A typical application consists of a set of classes that represent its business logic. In object-oriented programming this logic should always be present in some form. This business logic is represented by rows in the Wpf GridControl without regard to specific model used. When a programmer changes data object values in non-event-driven data grids, he has to find rows in the data grid and sort them, group them and verify their filtering criteria. It's important to remember that in well-designed applications it is necessary to take care about thread safety. In event-driven model, a data grid receives notifications about data changes and performs all the above mentioned operations.
Copy | |
---|---|
//Some data object public class Product : INotifyPropertyChanged { //Some fields private double price; private DateTime maturity; [DoubleConverter(Precision = 3, ShortForm = true, ShowZero = false)] public double Price { get { return price; } set { price = value; if(PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Price")); } } } public DateTime Maturity { get { return maturity; } } public event PropertyChangedEventHandler PropertyChanged; } //Using sample public void AddDataObjectToGrid(GridControl grid) { //Initialize the grid grid.Headers.Add(new Header()); grid.Headers[0].Add(new Column("Price")); grid.Headers[0].Add(new Column("Maturity")); //Add a data object to grid. The object is implicitly wrapped with DataObjectAccessor grid.Rows.Add(new Product()); //Add a data object to grid and wrap it explicitly with DataObjectAccessor //(You can provide your custom implementation of the data accessor). grid.Rows.Add(new DataObjectAccessor(new Product())); //Build some hierarchy... grid.Rows[0].Add(new Product()); //Or from another thread - this is safe. ThreadPool.QueueUserWorkItem(delegate { grid.Rows[0].Add(new Product()); }); } |
Inheritance Hierarchy
Dapfor.Wpf.Data..::..DataObjectAccessorBase
Dapfor.Wpf.Data..::..DataObjectAccessor