c# - Switch order of item in Observable Collection - UWP
问题描述
Say I have 3 items in my observable collection and I want to swap the "indexes" of item1 (index of 1) and item2 (index of 2) so that item1 has an index of 2 and item2 has an index of 1. How easy is this to do? In needs to also be reflected in the UI where my ListView's itemsource is bound to the observable collection.
Thanks :)
解决方案
ObservableCollection<T>
有一个MoveItem(int oldIndex, int newIndex)
功能。看这里https://docs.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1.moveitem?view=netframework-4.8
推荐阅读
- javascript - 仅设置某些项目时如何查询缓存?
- amazon-web-services - boto3 会话持续多长时间?在我的服务中,我希望从多个区域获取实例并考虑为每个区域创建一个会话
- terraform - 如何使用 Terraform 调整 vmWare Cloud Director 中的计算机名称属性?
- r - 在 r 中最大化/优化具有约束的函数
- typescript - mathjs 数字只有打字稿?
- swift - 在 ReactiveSwift 中同步组合属性
- python - 如何通过python中的正则表达式替换/修改模式?
- c# - 在 for 循环中存储数据
- html - 让 div 在屏幕底部而不是在父底部
- javascript - 如何过滤 Firebase 和 Ionic 中的数据?