I am building a WPF grid right now and am trying to sort it on a property of a M:1 entity that the grid is bound to. Microsoft has many examples of using a SortDescription in the dataview that the grid is bound to in order to accomplish this, but I can't figure out how to set this sort description equal to the property of a related entity...
So, say I have a list of OrderItem entities. Each OrderItem has an Order entity attached. The list of OrderItem entities is bound to a wpf listview (with a gridview inside). I know I can sort this gridview by the OrderItem.Id property with something like:
ICollectionView dataView = CollectionViewSource.GetDefaultView(TheListView.ItemsSource);
dataView.SortDescriptions.Add( New SortDescription("Id", ListSortDirection.Ascending);
dataView.Refresh();
However, I want to sort by the name of the Order entity...I know I can add a field based on a related entity to the OrderItem entity, but I would prefer not to do this as I would be littering the entities with GUI properties.
Is there a way to do this with something like:
ICollectionView dataView = CollectionViewSource.GetDefaultView(TheListView.ItemsSource);
dataView.SortDescriptions.Add( New SortDescription("Order.Name", ListSortDirection.Ascending);
dataView.Refresh();
where "Order" is the name of the related entity property?