直接使用DataGrid.ItemsSource = adp绑定的是一个名为Length的列,显示的是每个项的长度;
需要使用 .Select(x => new { Value = x }).ToList() 才能展示值;
private void Button_Click_1(object sender, RoutedEventArgs e) { new Thread(() => { List<string> adp = MySqlHelper.selectSQL("select name from perinfo;"); this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate { DataGrid.ItemsSource = adp.Select(x => new { Value = x }).ToList(); }); }).Start(); }