You may also like...

15 Responses

  1. JAH says:

    Lines of code are cut off in this post. Is there a place I can examine the code?

    Regards

  2. ekampf says:

    Hi JAH,
    Thanks for the heads up. Layout must have gone bad with my latest migration to WordPress.

    I’ve fixed the post and the code should be clear and visible now.

    I will post complete code for the Stocky sample application very soon.

    Regards,
    Eran

  3. ekampf says:

    The file for this post is available at:

  4. JAH says:

    Hi Eran,

    Ther is a reference to what I think is a function call to “VerifyPropertyNameIsValid(propertyName);” but I can’f find the function?

    Regards

  5. JAH says:

    Hi Eran,

    I found it, Thanks

    Regards

  6. ekampf says:

    Fixed paragraphs etc. too

  7. Joel says:

    Eran,

    I’m a VB.Net developer and am having some dificulty translating the C#.NET code (Especially the event handling code). Is there going to be a VB.NET version of this code? Is it posible to send you what I have so far to proof? This way we can put a VB.Net version out there?

    Thanx
    Joel

  8. ekampf says:

    Hi Joel,
    There isn’t going to be a VB version (at least not by me) as I won’t be a very helpful proof reader as I have never used it.

    However, the only event handling code here is the very basic of defining a delegate variable – _propertyChangedEvent, and calling it.

    You can find code sample for implementing INotifyPropertyChanged here:
    http://msdn.microsoft.com/en-us/library/ms229614.aspx

    Let me know how it goes…

    Regards,
    Eran

  9. Joel says:

    Hi Eran,

    Can you explain the following statements, I think I know what it’s doing but not sure. Is it adding and removing event handlers from a generic list?

    public event PropertyChangedEventHandler PropertyChanged
    {
    add
    {
    VerifyCalledOnUIThread();
    _propertyChangedEvent += value;
    }
    remove
    {
    VerifyCalledOnUIThread();
    _propertyChangedEvent -= value;
    }
    }

    Thanx
    Joel

  10. ekampf says:

    Hi Joel,
    We override the default behavior of the event’s Add\Remove to verify they’re only called from the UI thread.

    As written in the post:

    “Since adding\removing event handlers to the PropertyChanged event is a public API exposed by the DataModel, it also requires verification that calls to it are made from the UI thread.”

    Regards,
    Eran

  11. Joel says:

    Hi Eran,

    Not being a C# developer I was trying to interpret what the “_propertyChangedEvent += value;” was doing. Is it placing an event into a generic list of events?

    Thanx
    Joel

  12. Joel says:

    Hi Eran,

    I figured it out and completed a VB.Net version of your code that works, would you like a copy to post for those that only know VB.Net?

    Regards

  13. ekampf says:

    Joel,
    Glad to hear you got the thing working. I’ll be glad to check it out and add to it the post (or link external to your site if you have one)

    Regards,
    Eran

  14. Joel says:

    Hi Eran,

    How can I get the code to you?

    Regards

  15. ekampf says:

    email to eran at ekampf.com