List<T> 数据源

来源:互联网 发布:简单的c语言编程例题 编辑:程序博客网 时间:2024/06/06 11:45




  List<Data> dataSource = new List<Data>();         List<Data> GetData()        {            dataSource.Add(new Data { Key = 1, Value = "US" });            dataSource.Add(new Data { Key = 2, Value = "China" });            return dataSource;        }        public void DataBind()        {            ComboBoxbaud.ItemsSource = GetData();            ComboBoxbaud.DisplayMemberPath = "Value";            ComboBoxbaud.SelectedValuePath = "Key";            ComboBoxbaud.SelectedValue = 1;        }

     class Data    {        public int Key{ set; get; }        public string Value { set; get; }     }


0 0