Results 1 to 2 of 2

Thread: Raise event on changing a collection

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    263

    Raise event on changing a collection

    Hi,

    is it possible to raise an event to handle adding items to lstAnimals


    Code:
            class Zoo
            {
                string name { get; set; }
                List<Animal> lstAnimals { get; set; }
            }
    
            class Animal
            {
                string name { get; set; }
            }

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,648

    Re: Raise event on changing a collection

    You would need to use an ObservableCollection rather than a List.

    By the way, except in quite particular circumstances, a collection property really should be read-only.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width