Hi,
you can use a class
public class MyClass
{
public string Name {get;set;}
public int Code { get; set; }
}
and create in the Linqstatement no var. You create new objects from your class:
dataGrid1.DataContext = from re in MainWindow.mcsEntity.mcs_hall
orderby re.mcs_Hall_Code
select new MyClass
{
Name = re.mcs_Hall_Name,
Code = re.mcs_Hall_Code
};
in your SelectionChanged event you convert the selectedItem to your class:
private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
textBox1.Text = (e.AddedItems[0] as MyClass).Name;
}
}
Hope that helps