zoukankan      html  css  js  c++  java
  • Silverlight 2.0 beta 2学习笔记(2)

    重要的很有用的接口:

    INotifyPropertyChanged

    功能:

    向客户端发出某一属性值已更改的通知。


    只有一个事件:PropertyChanged

    在更改属性值时发生。



    示例:
    // This class implements a simple customer type 
    // that implements the IPropertyChange interface.
    public class DemoCustomer : INotifyPropertyChanged
    {
        
    // These fields hold the values for the public properties.
        private Guid idValue = Guid.NewGuid();
        
    private string customerName = String.Empty;
        
    private string companyNameValue = String.Empty;
        
    private string phoneNumberValue = String.Empty;

        
    public event PropertyChangedEventHandler PropertyChanged;
        
        
    private void NotifyPropertyChanged(String info)
        
    {
            
    if (PropertyChanged != null)
            
    {
                PropertyChanged(
    thisnew PropertyChangedEventArgs(info));
            }

        }


        
    // The constructor is private to enforce the factory pattern.
        private DemoCustomer()
        
    {
            customerName 
    = "no data";
            companyNameValue 
    = "no data";
            phoneNumberValue 
    = "no data";
        }


        
    // This is the public factory method.
        public static DemoCustomer CreateNewCustomer()
        
    {
            
    return new DemoCustomer();
        }


        
    // This property represents an ID, suitable
        
    // for use as a primary key in a database.
        public Guid ID
        
    {
            
    get
            
    {
                
    return this.idValue;
            }

        }


        
    public string CompanyName
        
    {
            
    get
            
    {
                
    return this.companyNameValue;
            }


            
    set
            
    {
                
    if (value != this.companyNameValue)
                
    {
                    
    this.companyNameValue = value;
                    NotifyPropertyChanged(
    "CompanyName");
                }

            }

        }


        
    public string PhoneNumber
        
    {
            
    get
            
    {
                
    return this.phoneNumberValue;
            }


            
    set
            
    {
                
    if (value != this.phoneNumberValue)
                
    {
                    
    this.phoneNumberValue = value;
                    NotifyPropertyChanged(
    "PhoneNumber");
                }

            }

        }

    }
  • 相关阅读:
    thinkphp配置加载
    thinkphp数据输出
    thinkphp 命名规范
    array_fill — 用给定的值填充数组
    array_fill_keys — 使用指定的键和值填充数组
    array_change_key_case — 将数组中的所有键名修改为全大写或小写
    HTMLCSS样式表
    MySql查询语句中的变量使用
    使用java8的方法引用替换硬编码
    如何搭建一个自己的网站(绝对详细~)
  • 原文地址:https://www.cnblogs.com/boywujch/p/1238651.html
Copyright © 2011-2022 走看看