I have the following to get data from an Entity Framework 4:
IQueryable<Exam> examsQuery =
entities.CreateQuery<Exam>("[Exams]").Include("Course");
exams =
new EntityObservableCollection<Exam>(entities, "Exams", examsQuery);
In my viewmodel I have the following code:
public IEnumerable<Exam> Exams { get { return exams; } }
And in my XAML the following:
<ListView ItemsSource="{Binding Exams}" SelectedItem="{Binding SelectedExam}"
SelectionChanged="ListViewSelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Code}" Header="ExamCode" Width="250"/>
<GridViewColumn DisplayMemberBinding="{Binding Desc}" Header="Desc" Width="150"/>
<GridViewColumn DisplayMemberBinding="{Binding Course.Code}" Header="Course" Width="150"/>
</GridView>
</ListView.View>
</ListView>
The problem for me is that firstly I would like to have:
1) ListView sorted on ExamCode column 2) I would like to have it remain sorted if for example the ExamCode is changed externally.
Is there an easy way to always keep a listview sorted? I have looked around and can't find a solution at all.
Thanks