Loading

[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");
        }
    }

 效果:

posted @ 2019-01-29 12:25  李正浩  阅读(623)  评论(0编辑  收藏  举报