wpf - INotifyPropertyChanged with derive class -
i have class:
public class myfileinfo : inotifypropertychanged { private string _file; private int _bytessent; public myfileinfo(string file) { } public string file { { return _file; } set { _file = value; } } public int bytessent { { return _bytessent; } set { _bytessent= value; } } }
and derive class:
public class myfile : myfileinfo { }
so every time _bytessent
has changed want notify:
public event propertychangedeventhandler propertychanged; public virtual void notifypropertychange(string propertyname) { var handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); }
using this:
public static int propertyname { { return _propertyname; } set { _totalpacketssent = value; notifypropertychange("..."); } }
so question is: should declare event ? in base class on 1 derive
by convention, should define in base class protected virtual name "oneventname":
protected virtual void onpropertychanged(string propertyname) { var handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); }
Comments
Post a Comment