I have a data grid which ItemsSource is binded to the result of LINQ to Entity query and in one column are EntityCollection objects.
private void DataGridRecipientsLoad()
{
dataGridRecipients.ItemsSource = from rec in _recipientService.GetAllRecipients()
select rec;
dataGridRecipients.Columns[7].Visibility = System.Windows.Visibility.Collapsed;
dataGridRecipients.Columns[8].Visibility = System.Windows.Visibility.Collapsed;
}
How can I create a template in C# that takes out just string properties out of the items in Entity Collection and displays them? Right now the cells are empty.
The EntityCollection consists entities called MailingList and I want to display myMailingList.Name of each of them.
For example, you have collection of customers and of them has the next properties:
FirstNameandLastName:then you can simple grid view for it:
And you also need to assign
ItemSource(as you did in you code).You can also write more flexible templates for your need using
DataGridTemplateColumn.I suggest you read more about xaml templates. (this link/another link has nice samples).
p.s.Also when i see such questions i allways suggest to read about MVVM.