Bindable UserControl stops updating when an event member is added

Bindable UserControl stops updating when an event member is added

Old forum URL:

Troncho posted on Friday, November 09, 2012



public partial class UCNrgHelpBase : UserControl


public event EventHandler<NrgHelpBaseEventArgs> InfoObjChanged;

   public virtual IReadOnlyInfo InfoObj {...}




If I comment the event (InfoObjChanged), DataBinding works perfectly well.

If I just leave the event (InfoObjChanged) decleared,

even without using it anywhere, the control's bindable property

updates just fine but the DataSource property never gets updated.

Do you know what I may be missing here?




Troncho replied on Saturday, November 10, 2012

I found the problem!

It seems that, behind the curtains, when you declare a class with the attribute:


It generates some hidden event for DataBinding handling or something with the following name: [PropertyName + "Changed"].

So, when I declared the

public event EventHandler<NrgHelpBaseEventArgsInfoObjChanged;

it seems to suppress the underlaying behaivour for DataBinding to work correctly.

Just fooling around, I begun changing EventHandler types and names, and I got it working.

The result being that I only changed my custom event handler's name to:

public event EventHandler<NrgHelpBaseEventArgsInfoObj_ValueChanged;

And it all fall into place. Now DataBinding is working again just fine and my custom event is firing just as well.

So, problem seems to be solved.


Copyright (c) Marimer LLC