数据集刷新后保持 TreeView 子树展开
我正在使用 .Net RIA 服务的 7 月 '09 CTP,并将 Group=>Department=>Category 对象的对象绑定到树视图,然后让 hierarchialdatatemplate 呈现三种对象类型中的每一种。
我的最终目标是启用拖放功能,以便我可以快速编辑组列表 => 部门 => 类别,并以比以前更直观的方式更改它们各自的关系可用的。
我当前的问题是,当我执行 drop 命令并提交需要提交到数据上下文的更改时,我的树视图正在重绘并折叠叶子。有没有什么方法可以避免崩溃?
I'm working with the July '09 CTP of the .Net RIA services, and binding an object of Group=>Department=>Category objects to a treeview, and then having a hierarchialdatatemplate render each of the three object types.
What my end goal is for this will be to enable drag-n-drop functionality so that I can quickly edit my list of groups=>departments=>categories, and change their respective relationships in a more intuitive manner than what was previously available.
My current issue is that when I do the drop command, and submit the changes that need to be submitted to the data context, my treeview is redrawing, and collapsing the leaves. Is there a method by which I can use to avoid the collapse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发布这个答案纯粹是为了那些偶然发现这个帖子寻找答案的人。 (在 SL4 中完成)
您需要 2 个列表:
您还必须确保您的 Load 操作的 LoadBehaviour 设置为 Merge。
例如:
所以现在剩下的就是在每次更新后调用您的domainContext.Load,并在您的CallbackFunction中将您的sourceList替换为Web服务返回的新实体列表。由于显示列表的向下钻取条目依赖于关联和分层数据模板,因此它仍应在刚刚编辑的条目上展开。
注意如果您从头开始重建 DisplayList,树视图显然会重绘\折叠。
希望这对某人有帮助。
扬
I'm posting this answer purely for those who stumble upon this thread looking for an answer. (was done in SL4)
you'll need 2 lists:
you also must make sure that your Load operation has its LoadBehaviour set to Merge.
for example:
so all that remains now is to call your domainContext.Load after each update and in your CallbackFunction replace your sourceList with the new list of entities returned by the web service. Since your Display list's drill down entries relies on association and the hierarchical Data template it should still be expanded on the entry that was just edited.
Note if you rebuild the DisplayList from scratch the treeview would obviously redraw\collapse.
Hope this helps someone.
Jan
我没有做过很多 Silverlight 工作,但据我所知,它的对象模型相当有限,因此执行此操作的某些事件/属性/方法可能不存在。但是您可以尝试自己保存/恢复状态...类似于以下伪代码:
I've not done a lot of Silverlight work, but from what I've seen it has a pretty limited object model, so some of the events/properties/methods to do this may not be there. But you could try saving/restoring the state yourself... something akin to the following pseudo-code: