Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private static Visibility isenable;
       public static Visibility IsEnable
       {
           get
           {
               return isenable;
           }
           set
           {
               if (isenable != value)
               {
                   isenable = value;
                   OnPropertyChanged("IsEnable");
               }
           }
       }


C#
public abstract class ViewProperty : INotifyPropertyChanged, IDisposable
    {

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                var e = new PropertyChangedEventArgs(propertyName);
                handler(this, e);
            }
        }       

    }


OnpropertyChanged() method is a non static.

Is there any way to use OnpropertyChanged method for static properties?
Posted
Updated 12-Dec-11 19:41pm
v3

1 solution

I found solution using Delegates

public static EnableDelegate DelEnable = new EnableDelegate(DelCal);

C#
public delegate void EnableDelegate();
        private void DelCal()
        {
            OnPropertyChanged("IsEnable");
        }

C#
private static Visibility isenable;
       public static Visibility IsEnable
       {
           get
           {
               return isenable;
           }
           set
           {
               if (isenable != value)
               {
                   isenable = value;                   
               }
           }
       }

//Invoking delegate when changing the value

IsEnable = Visibility.Hidden;
DelEnable();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900