Search code examples
c#silverlight

how to get event of change in enum value?


I have created 1 enum when I use it as a property for a custom control, I want to fire a event for change of the enum property.Please Help.


Solution

  • Make use of the setter to call a function or to call an event delegate.

      public enum PersonName
      {
          Eric,
          George,
          David,
          Frank
      }
    
      private PersonName myPersonName
    
      public PersonName MyPersonName
      {
          get { return myPersonName; }
          set
          {
              myPersonName = value;
              //simply call what you want done
              PersonNamePropertyChanged();
          }
      }
    

    See more here http://msdn.microsoft.com/en-us/library/ms743695.aspx which is done using the INotifyPropertyChanged