开发者

Manually reordering a collectionview in wpf

开发者 https://www.devze.com 2023-04-04 18:14 出处:网络
I am trying to create a custom control that has the following features: 1. A horizontal listbox backed by a listcollectionview and ultimately an ObservableCollection.

I am trying to create a custom control that has the following features:

1. A horizontal listbox backed by a listcollectionview and ultimately an ObservableCollection.

2. Each of the listbox items has several properties usable for filtering and sorting e.g. name, datetime, etc.

3. A filter or sort rule could be applied either instantaneously or continuously.

a. Continuously: the rule is enforced as items are edited, added or removed.

b. Instantaneously: the rule is enforced once but that ordering is preserved as items or edited. This means items that are added could be at an index of the users choosing. In the continuous case they would obviously have the index determined by the sort/filter rules.

4. When a continuous filter is not applied the items should be re-orderable using drag and drop.

This initially seemed like a job for the collectionview as it allows the filtering parts to be done easily for the continuous case using IEditableObject.

I have a behaviour for drag and drop reordering which works fine when I edit the underlying collection at drop. I can't ed开发者_JAVA技巧it the collectionview by placing an element at index so its not quite the behavior I need. Also I dont really want to edit the underlying collection as the ordering is purely UI and the underlying collection could be used in multiple collectionview's.

So its point 4 I'm really stuck on. I have enough questions, posts and blogs about this to make my head spin and I am sure that I am either missing something obvious or its just not possible without inheriting from collectionview or similar.

Any kick in the right direction appreciated.

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号