CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Bindable UserControl stops updating when an event member is added

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 1 Reply | 1 Follower

    Top 200 Contributor
    45 Posts
    Troncho posted on Fri, Nov 9 2012 10:47 PM

    [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

    Answered (Verified) Verified Answer

    Top 200 Contributor
    45 Posts
    Verified by 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<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.

    Troncho

    Page 1 of 1 (2 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems