[WPF]使用Fody提高效率
下载安装及使用
代码实例
public class Person:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string Name { get; set; }
[DependsOn(nameof(Name))]
public int length => Name.Length;
}
class Program
{
static void Main(string[] args)
{
var per=new Person();
per.PropertyChanged += Per_PropertyChanged;
per.Name = "lizhenghao";
per.Name = "lizhenghao";
per.Name = "123";
}
private static void Per_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Console.WriteLine($"Property {e.PropertyName} changed");
}
}
效果:
https://github.com/li-zheng-hao