既然是绑定,那么就通过数据源获取就好了。
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private List
private List
private void Window_Loaded(object sender, RoutedEventArgs e)
{
list.AddRange(new Test[] { new Test { Title = "1" }, new Test { Title = "2" }, new Test { Title = "3" } });
//*****************
list_s = (from l in list select l).ToList();
this.datagrid.ItemsSource = list_s;
MessageBox.Show(list_s[2].Title);
}
}
public class Test
{
public string Title
{
get { return this.title; }
set { this.title = value; }
}
private string title = string.Empty;
}