We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add PropertyChanged to inheritable class

Hello.

My class inherits from the class KanbanViewModel.

It has the variable property "BackgroundColor". How can I hang on him "PropertyChanged"?

public class KanbanViewModel : KanbanModel
{
    private Brush _backgroundColor;
    public Brush BackgroundColor
    {
        get { return _backgroundColor; }
        set
        {
 
           ???
        }
 
    }
}

2 Replies

AA Andrei Alfritovich Bilalov December 11, 2016 07:15 AM UTC

My problem - I can't use INotifyProperyChanged, because KanbanModel already implement this interface.


SK Satheesh Kumar T Syncfusion Team December 12, 2016 05:14 AM UTC

Hi Andrei, 

Thanks for contacting Syncfusion Support. 

We can notify the property changed for the property in the class which inherits the KanbanModel class. Please refer the below code sample to notify the property changed. 

Code sample: 

[C#] 

 
public class KanbanViewModel : KanbanModel 
{ 
       private MethodInfo _methodInfo; 
 
       private Brush _backgroundColor; 
 
       public Brush BackgroundColor 
       { 
              get { return _backgroundColor; } 
              set 
              { 
                     _backgroundColor = value; 
                     if (_methodInfo != null) 
                           _methodInfo.Invoke(this, new object[] { "BackgroundColor" }); 
              } 
       } 
               
       public KanbanViewModel() 
       { 
              //Reflected the NotifyPropertyChanged method.  
              _methodInfo = this.GetType().GetMethod("NotifyPropertyChanged", BindingFlags.NonPublic | BindingFlags.Instance); 
       } 
} 


Thanks, 
Satheesh  


Loader.
Up arrow icon