ObservableCollection 分组后排序报错问题
ObservableCollection通过Move方法可以移动顺序,如下:
将ObservableCollection中的一个item置顶:
private ObservableCollection<GroupListInfo> _disCussItems;
private void TopItem(string groupName)
{
var info = _disCussItems.FirstOrDefault(m => m.GroupName == groupName);
if (info == null) return;
var index = _disCussItems.IndexOf(info);
if (index < ) return;
_disCussItems.Move(index, );
}
但是当ObservableCollection分组后,
var vw = CollectionViewSource.GetDefaultView(_disCussItems);
vw.GroupDescriptions.Add(new PropertyGroupDescription("TimeGroup"));//按TimeGroup字段分组
Move方法就会出现错误,
大概猜测排序后每个组的index都是在各自的组内,最后只能做一个兼容的操作:
就是在调用Move方法之前,先清空分组;
待move方法完成后,在调用分组功能,具体如下:
private ObservableCollection<GroupListInfo> _disCussItems;
private void TopItem(string groupName)
{
var info = _disCussItems.FirstOrDefault(m => m.GroupName == groupName);
if (info == null) return;
var vw = CollectionViewSource.GetDefaultView(_disCussItems);
vw.GroupDescriptions.Clear();
var index = _disCussItems.IndexOf(info);
if (index < ) return;
_disCussItems.Move(index, );
vw.GroupDescriptions.Add(new PropertyGroupDescription("TimeGroup"));
}
ObservableCollection 分组后排序报错问题的更多相关文章
- 排序(分组后排序&整排)
一.整排 要求:根据score进行排名,分数相同,名次相同,且连续 表如下图: sql语句: 方法一:select a.score, (select count(distinct b.score) f ...
- ES使用text类型字段排序报错
elasticsearch text字段排序报错解决使用elasticsearch 进行排序的时候,我们一般都会排序数字.日期.但是在排序text类型的时候就会出现错误. GET xytest/sut ...
- dialogic d300语音卡驱动重装后启动报错问题解决方法
dialogic d300 驱动重装后 dlstart 报错解决 问题描述:dlstart 后如下报错 [root@BJAPQ091 data]#dlstop Stopping Dialogic ...
- Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer
Heka 编译安装后 运行报错 panic: runtime error: cgo argument has Go pointer to Go pointer 解决办法: 1. Start heka ...
- 安装mongodb后启动报错libstdc++
安装mongo后启动报错如下图 显然说是libstdc++.so文件版本的问题,这种一般都是gcc版本太低了 接着查询gcc的版本 strings /usr/lib/libstdc++.so.6 ...
- Maven项目下update maven后Eclipse报错:java.lang.ClassNotFoundException: ContextLoaderL
Maven项目下update maven后Eclipse报错:java.lang.ClassNotFoundException: ContextLoaderL 严重: Error config ...
- linux上安装完torch后仍报错:ImportError: No module named torch
linux上安装完torch后仍报错: Traceback (most recent call last): File , in <module> import torch ImportE ...
- 安卓工作室 android studio 汉化后,报错。 设置界面打不开。Can't find resource for bundle java.util.PropertyResourceBundle, key emmet.bem.class.name.element.separator.label
安卓工作室 android studio 汉化后,报错. 设置界面打不开. Android studio has been sinified and reported wrong.The setup ...
- Python首次安装后运行报错(0xc000007b)的解决方法
最近在安装完Python后运行发现居然报错了,错误代码是0xc000007b,于是通过往上查找发现是因为首次安装Python缺乏VC++库的原因,下面通过这篇文章看看如何解决这个问题吧. 错误提示 ...
随机推荐
- Data Structure Array: Largest subarray with equal number of 0s and 1s
http://www.geeksforgeeks.org/largest-subarray-with-equal-number-of-0s-and-1s/ #include <iostream& ...
- mysql高可用研究(一) 主从+MHA架构
最近在研究mysql的高可用架构,自己想总结下常用的高可用方案都有哪些.有哪些优缺点以及应用的场景?搞得是头昏脑涨,天昏地暗,看了诸多资料,每次都觉得公说公有理婆说婆有理.其实嘛,大家说的都有一定的道 ...
- 纯CSS3垂直动画菜单
在线演示 本地下载
- EntityFramework 学习 一 Add Entity Graph using DbContext:
//Create student in disconnected mode Student newStudent = new Student() { StudentName = "New S ...
- jQuery绑定事件的四种方式区别
jQuery中提供了四种事件监听方式,分别是bind.live.delegate.on,对应的解除监听的函数分别是unbind.die.undelegate.off.在开始看他们之前 一:bind(t ...
- css 网站素装 追忆过去
素装代码,以表哀悼等.以下为全站CSS代码. html { filter: grayscale(100%); -webkit-filter: grayscale(100%); -moz-filter: ...
- 异步刷新页面的前进与后退的实现--pushState replaceState
实现目标 页面的跳转(前进后退,点击等)不重新请求页面 页面URL与页面展现内容一致(符合人们对传统网页的认识) 在不支持的浏览器下降级成传统网页的方式 使用到的API history.state 当 ...
- PHP不用第三变量交换2个变量的值的解决方法
以前做过一道php面试题是这样的:不使用第三个变量实现交换两个变量的值.一般都是借助第三个中间变量来实现原来两个变量的值交换,但是这道题却要求不能使用中间变量,这对于初学者来说也算是一个难题了.网上找 ...
- [转]Eclipse快捷键_01_常用快捷键汇总
(注:红色标出来的是经常使用到的快捷键,磨刀不误砍柴工啊...) 一.常用快捷键 Shift+Alt+L: 自动补全等号左边对象 .(用鼠标选中这一行,然后按组合键Shift+Alt+L,在弹出的对 ...
- 第二章 python基础(二)
第九节 函数 函数就是完成特定功能的一个语句组,这组语句可以作为一个单位使用,并且给它取一个名字. 可以通过函数名在程序的不同地方多次执行(这通常叫做函数调用),却不需要在所有地方都重复编写这些语句. ...