Damien Morton

Ive been heavily using databinding to build my application, specifically having a bindingsource on a form, to which all properties are bound.

I noticed today that when a notification of change for a single property is fired, all properties refresh their values.

This is very much undesireable behavior. When I tell the system that one property has changed, I expect that only one property will be updated.

I think I understand whats going on - the BindingSource converts PropertyChanged events into ListChanged events, and ListChanged events have whole-object granularity.

Does anyone have any suggestions as to how to get back the fine-grained PropertyChanged upadtes, while still keeping the data binding ease of use that the BindingSource gives us



Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

I tried binding directly to the object, and not through the BindingSource - the same thing happens - all the bound controls refresh their bound properties.





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

does no-one have anything usefull to say about this





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Luc Morin

Hi,

May I ask why it's a problem for you that all properties update their content

Luc





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

timvw

I've been in situations where some of the properties where the result of heavy calculations.. In that case it can become cumbersome.. The fastest/easiest work-around for this problem is to cache the values in the object that implements INotifyPropretyChanged.





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

Consider the situation where several properties are updating frequently - it seems wastefull to refresh all of the properties each time one updates.

If producing the properties is an expensive operation, then things rapidly get out of control.

Its also a problem because the implicit promise of INotifyPropertyChanged is that a class implementing this interface can notify that a single property has changed. The current semantics are that this is the same as notifying that all properties have changed. Its completely unintuitive that notifying that a single property has changed will result in all of them being updated, and you can only find out that this is happening by tracing and debugging - theres absolutely no mention of this behavior anywhere in the documentation.





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Luc Morin

Hi,

Could you give a bit more details about your use-case

I've done a quick test with a custom BO to see if indeed every properties are "refreshed" when one of them raises the PropertyChanged event. What I notice is that ONLY the property that raised the event is re-queried by the databinding framework.

Basically, I have a Form with 2 textboxes, bound through a BindingSource to a BO with 2 properties. Setting a breakpoint on the 2 "getters" shows that only the modified property is requeried.

Maybe you have things setup differently, so if you give more details we can figure out what's going on.

Or maybe I don't understand your problem If that's the case, sorry.

Luc





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

Hi Luc,

You understand the problem perfectly, and from what you describe you have set up the same test case as me.

Not sure why you are seeing different results, though. Ill post a link to my test app when I get home tonight. Perhaps you could do the same

Regards,

Damien





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

Ive uploaded my version of the test to www.bitfurnace.com/WindowsApplication21.zip





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Luc Morin

Damien,

You are right about all properties being re-queried.

One thing I notice is that it only happens when one of the properties is changed in code. It doesn't happen when the property is changed through a bound control such as TextBox. I had only done my tests with the later scenario.

This is indeed a bad thing if, as you mentioned, the property getters do intensive computations.

I'll need to check a few things, and I'll get back to you.

Luc





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Damien Morton

If the properties are changed directly through the binding, then no INotifyPropertyChanged event is fired. Its only INotifyPropertyChanged that gets transmuted into INotifyEverythingChanged, and this happens through by changing property notifications into ListChanged notifications.





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

Lex007

Hi,

I've got the same problem. I am using the object model from NetTiers (www.nettiers.com).

Can someone give a clear solution





Re: Windows Forms Data Controls and Databinding INotifyPropertyChanged event through BindingSource updates all bound properties on a form

aztec2_step

Has there been any solution for this problem

Please advise!