• 我想大部分的WPF和SL开发者都应该对INotifyPropertyChanged这个接口再熟悉不过了。


    #region Copyright PwC GDC Sep. 2010
    //
    // All rights are reserved. Reproduction or transmission in whole or in part, in
    // any form or by any means, electronic, mechanical or otherwise, is prohibited
    // without the prior written consent of the copyright owner.
    //
    // Author:John Shao Sep.20.2010
    //
    #endregion
    
    using System.ComponentModel;
    
    namespace PwC.FCPA.ViewModel
    {
        /// <summary>
        /// ViewModel base class and implement INotifyPropertyChanged interface
        /// </summary>
        public abstract class ViewModelBase : INotifyPropertyChanged
        {
            #region INotifyPropertyChanged
            /// <summary>
            /// Property Change Event
            /// </summary>
            public event PropertyChangedEventHandler PropertyChanged;
    
            /// <summary>
            /// Implement INotifyPropertyChanged's function, when binding data in UI control
            /// this function will invoke PropertyChanged event.
            /// </summary>
            /// <param name="propertyName">Property Name</param>
            public virtual void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
            #endregion
        }
    }
    

      当我们向UI传递属性变化的通知并更新客户端UI时就必须应用到它。(这里插一句,当一个集合中的项改变时我们则需要使用ObservableCollection<T>泛型集合)

  • 相关阅读:
    下载linux历史版本
    CentOS7 常用命令集合
    oracle初级系列教程
    redis内存数据的持久化方式
    使用Spring 或Spring Boot实现读写分离( MySQL实现主从复制)
    三个线程ABC,交替打印ABC
    wait,notify,notifyAll详细介绍
    索引优化分析
    Git常用命令使用大全
    长连接 、短连接、心跳机制与断线重连(转载)
  • 原文地址:https://www.cnblogs.com/jobs2/p/2875153.html
Copyright © 2020-2023  润新知