zoukankan      html  css  js  c++  java
  • WPF listView中【checkbox】实现全选功能

      List<xxx> nn = new List<xxx>();
            public MainWindow()
            {
                InitializeComponent();
    
                for (int i = 0; i < 10; i++)
                {
                    nn.Add(new xxx { name = "nihaohao" + i, bol = false });
                }
                listview.ItemsSource = nn;
            }
    
            // public bool bb { get; set; }
            
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                foreach (xxx item in nn)
                {
                    //Debug.WriteLine(item.name + ":" + item.bol);
                    item.bol = true; //吧列表中checkbox属性设置为true
                }
            }
    
    //xxx 表类
    //实现INotifyPropertyChanged实现更改通知
    public class xxx : INotifyPropertyChanged
        {
            private string _name;
            public string name
            {
                get { return _name; }
                set
                {
                    _name = value;
                    OnPropertyChanged("name");
                }
            }
    
            private bool _bol;
            public bool bol
            {
                get { return _bol; }
                set
                {
                    _bol = value;
                    OnPropertyChanged("bol");
                }
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            public void OnPropertyChanged(string args)
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(args));
                Debug.WriteLine(name);
            }
        }
    

      

  • 相关阅读:
    ssd的BUG
    ImportError: No module named lmdb
    GPU卡掉卡
    mobileeye
    caffe convert mxnet
    学前书单-百科
    捉襟见肘
    caffe+opencv3.3.1
    ipython notebook开通远程
    到底什么是故事点(Story Point)?
  • 原文地址:https://www.cnblogs.com/jingxuan-li/p/7133498.html
Copyright © 2011-2022 走看看