• 数据绑定通知 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);

     
  • 相关阅读:
    php的语句
    php
    git分支
    git安装及git命令的用法
    git命令
    dos命令及github介绍
    无缝轮播的案例 及css3无缝轮播案例
    ACWING 031 表示数值的字符串
    Acwing 282. 石子合并 区间dp
    Leetcode 841. 钥匙和房间 dfs bfs
  • 原文地址:https://www.cnblogs.com/yunqie/p/7002732.html
Copyright © 2020-2023  润新知