[System.ComponentModel.DefaultBindingProperty("InfoObj")]
[DefaultEvent("InfoObjChanged")]
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?
Thanks,
Troncho
I found the problem!
It seems that, behind the curtains, when you declare a class with the attribute:
[System.ComponentModel.DefaultBindingProperty("InfoObj")]
It generates some hidden event for DataBinding handling or something with the following name: [PropertyName + "Changed"].
So, when I declared the
public event EventHandler<NrgHelpBaseEventArgs> InfoObjChanged;
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<NrgHelpBaseEventArgs> InfoObj_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.
Troncho
Copyright (c) Marimer LLC