zoukankan      html  css  js  c++  java
  • 数据绑定通知 INotifyPropertyChanged

    class BackgroundPath: INotifyPropertyChanged
        {
            BitmapImage bindSource = new BitmapImage(new Uri(PathShow.ImageSelected));      //预设值
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            public BitmapImage BindSource
            {
                set
                {
                    SetProperty(ref bindSource, value, "BindSource");}           
                get
                {
                    return bindSource;}           
            }
    
            protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName]string propertyName = null)
            {
                if (object.Equals(storage, value))
                    return false;
    
                storage = value;
                OnPropertyChanged(propertyName);
                return true;
            }
    
            protected void OnPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
       }


          Binding bind = new Binding()
          {
            Source = new BackgroundPath(),
            Path = new PropertyPath("BindSource")
          };
          faceImge.SetBinding(Image.SourceProperty,bind);

     
  • 相关阅读:
    在Visual Studio中使用NUnit
    C#调用Exe
    网页用chrome打开为乱码
    ctags最基本用法
    Facebook Connect
    SVM初体验
    python中可恶的回车符
    初识PowerDesigner
    Mysql中文乱码问题解决
    stat函数
  • 原文地址:https://www.cnblogs.com/yunqie/p/7002732.html
Copyright © 2011-2022 走看看