What I am looking for:
- All selected items to be shown on top.
Problem:
-
I have a custom incremental search control that populate the dropdown on incremental pattern. In the dropdown popup I have a ListView with ItemsSource set to a collection of unknown type. SelectionMode is Multiple.
-
ItemsSource is IsReadOnly
I need a solution to move the SelectedItem on top whenever a selection is made.
For me to solve this problem, there are various methods.
1) To implement the selectedindexchanged event in the listview. when the event is called, check all the items and move slected items to the top.
2) create a class inheriting from e.g. observablecollection. bind the selected property of the listview to a bool property of the objects in the collection(checkobject). When the bool property (of checkobject) changes (using propertychanged event), shift the object to the front (behind those that have bool = true). This way, you could keep the implementation in the collection class.
3) If the collection is readonly, a sort by the bool property can be used. However, this means that the object needs to be known
4) If the collection is unknown a custom sort can be used. One references is “Apply a custom sort rule to a wpf datagrid”