<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dapfor.Net Grid Blog &#187; Data binding</title>
	<atom:link href="http://www.blog.dapfor.com/data-binding/feed" rel="self" type="application/rss+xml" />
	<link>http://www.blog.dapfor.com</link>
	<description>.Net Grid and MFC Grid</description>
	<lastBuildDate>Fri, 09 Sep 2016 05:40:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Wpf GridControl v4.0.0 has been released</title>
		<link>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released</link>
		<comments>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released#comments</comments>
		<pubDate>Mon, 25 Apr 2016 15:49:54 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[new release]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[thread safety]]></category>
		<category><![CDATA[cell blinking]]></category>
		<category><![CDATA[datatemplate]]></category>
		<category><![CDATA[GridControl]]></category>
		<category><![CDATA[styles]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[Wpf]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=261</guid>
		<description><![CDATA[During development, we discovered that although WPF technology has many advantages, it utilizes a lot of computer resources. Therefore, creating a high quality and high performance product requires significant developer experience and deep understanding of technology. Out developers have invested of lot of effort in GridControl and as the result it has all the advantages of its [...]]]></description>
			<content:encoded><![CDATA[<p>During development, we discovered that although WPF technology has many advantages, it utilizes a lot of computer resources. Therefore, creating a high quality and high performance product requires significant developer experience and deep understanding of technology. Out developers have invested of lot of effort in <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol">GridControl</a> and as the result it has all the advantages of its predecessor, <a href="http://www.dapfor.com/en/net-suite/net-grid">.Net Grid</a>, including high performance.<br />
&nbsp;</p>
<div><img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features_6.png" alt="Wpf GridControl" width="685" height="411" align="center" /></div>
<p>&nbsp;</p>
<div>We have preserved <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/features/thread-safety">thread safety</a> of dynamic data in non-graphical thread enabling implementation of a thread-safe <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part3">event-driven model</a>. GridControl is the only graphical component that is able receive notifications (price changes or any other information) from the business model and from any thread.However, we mainly focused on ease of use, intuitiveness and minimization of code volume in final application. As the result, the grid supports <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part1">any data types</a>, creating any kind of <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/features/binding-row">hierarchy</a>, <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part9">sorting</a>, <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part11">filtering</a> and <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part10">grouping</a>. All of these features require just a few code lines.</p>
<p>The Wpf GridControl is the only component providing real-time services of simultaneous data grouping, sorting and filtering. This problem is very complex for developers to solve. As example, imagine blotter displaying several dozens shares sorted by constantly changing percentage of price fluctuation. In addition to that, users can apply filters to display only shares with the highest price change. A lot of complex and inefficient code is required to implement this functionality in other grid. Our GridControl has integrated data sorting, filtering and grouping services that continuously display rows in correct order even when they change all the time.<br />
&nbsp;
</p></div>
<div><img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features.png" alt="Wpf GridControl features" width="675" height="275" align="center" /></div>
<div>
&nbsp;<br />
We have also moved the feature of short-term <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part12">cell blinking</a> from .Net Grid to the new product. Users can set highlighting color and duration for individual cells using the provided callbacks.</p>
<p>We haven&#8217;t forgotten about specific advantages of WPF technology and now our application can display any controls in grid cells with <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part5">DataTemplate and DataTemplateSelector</a>. You can also alter grid appearance easily using <a href="http://www.dapfor.com/en/wpf-suite/gridcontrol/tutorial/tutorial-part6">preset or custom styles</a>.
</div>
<p>&nbsp;</p>
<div>
<img class="aligncenter" src="http://doc.dapfor.com/wpf-suite/media/features_5.png" alt="Wpf GridControl data templates" />
</div>
<p>&nbsp;</p>
<div>
We hope that you will be surprised by outstanding quality of our work and really appreciate it.</p>
<p>We believe that our products will deserve your attention and that with our help you will develop excellent high-performance user-friendly applications.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/wpf-gridcontrol-v4-0-0-has-been-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NetGrid v2.8.1 has been released. Hierarchical data relation</title>
		<link>http://www.blog.dapfor.com/netgrid-v2-8-1-has-been-released-hierarchical-data-relation</link>
		<comments>http://www.blog.dapfor.com/netgrid-v2-8-1-has-been-released-hierarchical-data-relation#comments</comments>
		<pubDate>Mon, 11 Jun 2012 21:19:52 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[new release]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[datarelation]]></category>
		<category><![CDATA[dataset]]></category>
		<category><![CDATA[datatable]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[netgrid]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=174</guid>
		<description><![CDATA[The main new feature in the version 2.8.1 is support for building a hierarchy of tables linked with DataRelation. &#160; New .Net Grid features: [NEW] Building hierarchy in a grid consisting of multiple tables using datarelation. The following bugs have been fixed: When a new theme was created basing on an existing theme, appearance data [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>The main new feature in the version 2.8.1 is support for building a hierarchy of tables linked with DataRelation.</p>
<div>
<img class="alignnone" src="http://support.dapfor.com/attachments/token/91yl5jh3nikmqex/?name=hierarchical_datarelation.png" alt="hierarchical_datarelation.png" width="592" height="179" />
</div>
<p>&nbsp;</p>
<div>
New .Net Grid features:</p>
<ul>
<li>[NEW] <a href="http://doc.dapfor.com/net-suite/html/4377638f-95cb-4a4b-be3d-90ccb57232c6.htm">Building hierarchy in a grid</a> consisting of multiple tables using datarelation.</li>
</ul>
<p>The following bugs have been fixed:</p>
<ul>
<li>When a new theme was created basing on an existing theme, appearance data was not copied. This resulted in simultaneous appearance changes in both themes.</li>
<li>Minor bug fixes.</li>
</ul>
</div>
<p>&nbsp;</p>
<p>We hope that you will appreciate grid quality, performance and convenience of interface. Let’s create feature-rich high-performance applications together.</p>
<p>Sincererly Yours,</p>
<p>Dapfor</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/netgrid-v2-8-1-has-been-released-hierarchical-data-relation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why BindingList is slow with objects implementing INotifyPropertyChanged interface</title>
		<link>http://www.blog.dapfor.com/why-bindinglist-is-slow-with-objects-implementing-inotifypropertychanged-interface</link>
		<comments>http://www.blog.dapfor.com/why-bindinglist-is-slow-with-objects-implementing-inotifypropertychanged-interface#comments</comments>
		<pubDate>Thu, 29 Mar 2012 18:59:31 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[BindingList]]></category>
		<category><![CDATA[INotifyPropertyChanged]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=139</guid>
		<description><![CDATA[A BindingList&#60;T&#62; is the main tool for binding objects to grids. It is a container that may notify subscribers when data is added or removed. For this purpose it provides public ListChanged event that specifies collection changes with ListChangedType. Besides changing the collection itself (adding, removing, etc) the binding list notifies of data object changes. [...]]]></description>
			<content:encoded><![CDATA[<p>A <strong>BindingList&lt;T&gt;</strong> is the main tool for binding objects to grids. It is a container that may notify subscribers when data is added or removed. For this purpose it provides public ListChanged event that specifies collection changes with ListChangedType. Besides changing the collection itself (adding, removing, etc) the binding list notifies of data object changes. In other words, when data is added to collection <strong>BindingList&lt;T&gt;</strong> checks whether it implements <strong>INotifyPropertyChanged</strong> interface. If it is implemented, the collection subscribes to each object changes and forwards notifications as <strong>IBindingList.ListChanged</strong> events with <strong>ListChangedType.ItemChanged</strong> type and with specified PropertyDescriptor that is searched by reflection. </p>
<p>It’s worth mentioning that handler of <strong>INotifyPropertyChanged</strong> notification is very poorly implemented. Low performance reflection is used for searching PropertyDescriptor and internal cache is very poorly organized thus significantly reducing performance. Specifically when the <strong>BindingList&lt;T&gt;</strong> receives notifications of new object, it compares this object with the previous object that was used for notification. If they are not identical, the binding list does a terrible thing – it runs through all objects to get the index of the notifying object. This seriously impacts performance when there are a lot of elements. When the number of elements is about 100 000, handling of a single notification takes about 1 ms, which is unacceptable for most applications. </p>
<p>In actual applications <strong>ListChangedType.ItemChanged</strong> event with <strong>ListChangedType.ItemChanged</strong> flag and set PropertyDescriptor is handled quite rarely. However, it is hard to disable <strong>INotifyPropertyChanged</strong> handling in a <strong>BindingList&lt;T&gt;</strong> via simple means. The only acceptable method of disabling handling is to use reflection. The thing is that the binding list in its constructor checks whether the data type implements <strong>INotifyPropertyChanged</strong> interface and sets <strong>raiseItemChangedEvents</strong> private variable to true if it does. Otherwise it is set to false. This variable influences only subscriptions to <strong>INotifyPropertyChanged</strong> interface. There is no direct access to this variable and it can be modified only via reflection. An example of code for this is provided below. </p>
<pre>
class CustomBindingList&lt;T&gt; : BindingList&lt;T&gt;
{
    public CustomBindingList()
    {
        FieldInfo fi = typeof (BindingList&lt;T&gt;).GetField("raiseItemChangedEvents",
                               BindingFlags.Instance | BindingFlags.NonPublic);
        if (fi != null)
        {
            fi.SetValue(this, false);
        }
    }
}
</pre>
<p><br/></p>
<p>The above implements fully functional binding list with disabled handling of <strong>INotifуPropertyChanged</strong> interface events. At the same time the binding list notifies subscribers of adding or removing data just like in standard implementation of this container. </p>
<p>Some figures: In standard binding list implementation handling of 1000 notifications in 100 000 container took more than 600 msec. In optimized version this time – 0 since the container no longer subscribes to data objects. Besides that, no subscription enables memory saving. </p>
<p>This article concerns only binding list performance aspects. Another important aspect of working with binding lists <strong>INotifyPropertyChanged</strong> is their use in <a href="http://www.dapfor.com/en/net-suite/net-grid/tutorial/data-binding">advanced binding</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/why-bindinglist-is-slow-with-objects-implementing-inotifypropertychanged-interface/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding list and thread safety</title>
		<link>http://www.blog.dapfor.com/binding-list-and-thread-safety</link>
		<comments>http://www.blog.dapfor.com/binding-list-and-thread-safety#comments</comments>
		<pubDate>Mon, 13 Feb 2012 21:05:28 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[thread safety]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[INotifyPropertyChanged]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[threadsafety]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=64</guid>
		<description><![CDATA[Data binding is the basis of modern applications based on separation of data layer from presentation layer. The main purpose of such separation is to make application logic independent of its representation. Otherwise, logic code should not directly call presentation layer class methods (i.e. Control class methods). When internal state changes, business logic layer sends [...]]]></description>
			<content:encoded><![CDATA[<p>Data binding is the basis of modern applications based on separation of data layer from presentation layer. The main purpose of such separation is to make application logic independent of its representation. Otherwise, logic code should not directly call presentation layer class methods (i.e. Control class methods). When internal state changes, business logic layer sends a GUI notification via <strong>IBindingList</strong> / <strong>INotifyPropertyChanged</strong> interfaces and the presentation layer displays modified data on screen. </p>
<p>It is necessary to note that there is a serious obstacle to implementing such event-driven model – thread safety. Business logic shouldn’t know anything of presentation, not only with regard to direct links to GUI classes but also with regard to thread used for subscriber notification. However, in actual applications things are more complicated. Application usually has a single GUI thread where the controls work. All control methods should be called only from this thread. However, data binding doesn’t consider this aspect, i.e. when a data source is connected, most controls imply that all notifications come from the main thread and don’t synchronize. This results in application crashes when notifications arrive from non-GUI thread. </p>
<p>While working with numerous real-world applications we have noted that developers often don’t follow the principle of separating data layer from the presentation layer because it is necessary to synchronize notifications with GUI thread. This means that synchronization is performed by business logic and not by the presentation layer. Thus, the required call of <strong>Control.Invoke</strong>/<strong>Control.BeginInvoke</strong> method is placed to business logic that should contain a reference to control that will process notifications. </p>
<pre>
class FeedCollection : BindingList&lt;Feed&gt;
{
    <strong>private Control _control;</strong>

    //The method is called when data is updated (for ex. data comes from TCP/IP)
    void OnUpdateReceiced(...)
    {
        _control.Invoke(new MethodInvoker(delegate
        {
            //Raise notification in GUI thread
            OnListChanged(new ListChangedEventArgs(...));
        }));
    }
}

DataGrid someGrid = ...;
FeedCollection feed = ...;
someGrid.DataSource = feed;
</pre>
<p><br/><br />
It is only one of the examples where rules of separating logic from presentation are violated. When our developers were working on .Net Grid, they have initially designed its architecture to receive notifications from any thread and to perform thread synchronization after that. Thus, business logic can be fully separated from the presentation layer and safely notify subscribers without pre-synchronization of threads and therefore without unnecessary references to GUI controls. </p>
<pre>
class FeedCollection : BindingList&lt;Feed&gt;
{
    //The method is called when data is updated (for ex. data comes from TCP/IP)
    void OnUpdateReceiced(...)
    {
        //Raise notification directly from non-GUI thread
        //Dapfor .Net Grid will synchronize threads itself.
        OnListChanged(new ListChangedEventArgs(...));
    }
}

Dapfor.Net.Ui.Grid grid = ...;
FeedCollection feed = ...;
grid.DataSource = feed;
</pre>
<p><br/></p>
<p>As we have said above, ensuring thread safety is not a trivial task for application developers. Complex modern applications may contain a  lot of assemblies. Some of them may contain codes with graphical controls, others may contain business logic, various math libraries, code  for TCP/IP interaction, etc. However, limitations related to GUI operation only in one thread and thread synchronization method require unneeded and dangerous dependencies of business logic from graphical components (Control.Invoke/Control.BeginInvoke).  This may seriously violate the principle of business logic independence from its presentation. Dapfor .Net Grid doesn’t just enable thread synchronization, but also makes it possible to completely avoid such dependencies using an event-driven model. It means that if the application is well architected,  business logic assemblies will not (and should not!) depend on Dapfor assemblies and System.Windows.Forms libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/binding-list-and-thread-safety/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Declarative data binding</title>
		<link>http://www.blog.dapfor.com/declarative-data-binding</link>
		<comments>http://www.blog.dapfor.com/declarative-data-binding#comments</comments>
		<pubDate>Thu, 09 Feb 2012 22:29:42 +0000</pubDate>
		<dc:creator>dapadm</dc:creator>
				<category><![CDATA[Data binding]]></category>
		<category><![CDATA[.Net Grid features]]></category>
		<category><![CDATA[databinding]]></category>
		<category><![CDATA[hierarchy]]></category>
		<category><![CDATA[IBindingList]]></category>
		<category><![CDATA[INotifyPropertyChanged]]></category>

		<guid isPermaLink="false">http://www.blog.dapfor.com/?p=39</guid>
		<description><![CDATA[Component model has two basic interfaces that are broadly used in data binding: INotifyPropertyChanged and IBindingList. The first interface notifies subscribers of bound object modifications while the second one notifies of object collection modifications. Object collections usually don’t contain hierarchy information and they are not intended for this purpose. Different grid developers use different ways [...]]]></description>
			<content:encoded><![CDATA[<p>Component model has two basic interfaces that are broadly used in data binding: <strong>INotifyPropertyChanged</strong> and <strong>IBindingList</strong>. The first interface notifies subscribers of bound object modifications while the second one notifies of object collection modifications. Object collections usually don’t contain hierarchy information and they are not intended for this purpose. Different grid developers use different ways to overcome this limitation. Some of them represent IBindingList as a collection containing objects linked by “id – parent id” relations, while the others expand IBindingList syntax adding hierarchy methods to it. We think that both solutions increase code overhead and reduce performance (which is critical for real time applications). </p>
<p>In our opinion, IBindingList should not contain hierarchy information. It is possible to use multiple binding lists to build it. For example, let’s take Strategy class that may contain multiple orders that can be dynamically added to this class or removed from it.</p>
<pre>
class Order
{
   ...
}

public class Strategy
{
    private readonly BindingList&lt;Order&gt; _orders = new BindingList&lt;Order&#038;gt();

    public IList&lt;Order&gt; Orders
    {
        get { return _orders; }
    }
}

//Add a new order to a strategy:
Order order = ...;
strategy.Orders.Add(order);

//Add a strategy to a grid
Strategy strategy = ...
grid.Rows.Add(strategy);
</pre>
<p><br/>Let’s note that when a strategy is added to the grid, it cannot display orders as it doesn’t have hierarchy information. It is possible to use declarative binding to tell the grid that <strong>Strategy.Orders</strong> field should be viewed as hierarchy foundation. </p>
<pre>
public class Strategy
{
    <strong>[HierarchicalField]</strong>
    public IList&lt;Order&gt; Orders
    {
        ...
    }
}
</pre>
<p><br/>When a strategy is added to the grid, it automatically subscribes to binding list returned by this strategy. It enables to use full-featured hierarchical binding with dynamic hierarchy modification without direct access to data presentation layer. To ensure complete separation of presentation layer from data layer we shall place strategy objects to <strong>IBindingList</strong>:</p>
<pre>
BindingList&lt;Strategy&gt; strategies = new BindingList&lt;Strategy&gt;();
//Populate collection with strategies
...

//Bind collection to the grid
grid.DataSource = strategies;

----- Strategies and orders will be presented in .Net Grid as following ---------------
+ Strategy
 |- Order
 |- Order
 | ...
+ Strategy
 |- Order
 |- Order
 | ...
</pre>
<p><br/>Conclusion:<br />
In our example we have achieved full separation of data from presentation. Data manipulation doesn’t require access to control, and this is true for hierarchical declarative data binding as well. Let’s also note that displayed data can be grouped, sorted and filtered without additional effort of the programmer. </p>
<p>In our opinion, the above hierarchy building method is one of the most efficient methods provided by the grid. Besides declarative binding, it is possible to build a hierarchy by simply adding data objects to any row. It is also possible to use conditional binding and binding on any hierarchy level.  </p>
<p>Programmers working with actual applications know how much code is required to complete a seemingly simple task of representing hierarchy data in the grid and synchronize it with grid presentation (adding and removing rows, etc). They will definitely appreciate our efforts in this field. </p>
<p>For more information of declarative data binding click <a href="http://www.dapfor.com/en/net-suite/net-grid/features/hierarchical-data-binding">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.dapfor.com/declarative-data-binding/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
