XAML:
<DataGridComboBoxColumn Header="Department"
ItemsSource="{Binding Source={StaticResource departmentViewSource}}"
DisplayMemberPath="Title" SelectedValuePath="ID" SortDirection="Ascending"
SelectedValueBinding="{Binding DepartmentID, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
SortMemberPath="lkpDepartments.Sequence" />
It appears to display the correct text, and link to the GUID correctly. But every variation that I have tried will not present the dropdown in order by the Sequence field (an int, no nulls, unique). Similar posts here aren't duplicates, because I'm using their solution and it still doesn't work.
Thanks.
The SortMemberPath
applies to the DataGrid
. It decides the property to sort by when you click on the column header.
To sort the ComboBox
, you should sort departmentViewSource
. You can for example do this by adding a SortDescription
to it in your XAML markup: https://learn.microsoft.com/en-us/dotnet/framework/wpf/data/how-to-sort-and-group-data-using-a-view-in-xaml.
If you are using the same CollectionViewSource
elsewhere and want different sort orders, you should define another one and bind the ComboBox
to this.