虚拟化WPF包装面板问题

编程入门 行业动态 更新时间:2024-10-28 11:19:42
本文介绍了虚拟化WPF包装面板问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在WPF中使用的虚拟包装面板没有太多选择。出于某种原因或另一种MS决定不将其发布到标准库中。

There are not very many options for a virtualizing wrap panel for use in WPF. For one reason or another MS decided to not ship one in the standard library.

如果有人敢于向公众提供答案(和解释),以下codeplex项目的第一个工作项目,我将不胜感激:

If anyone could be so bold as to provide a crowd source answer (and explaination) to the first work item on the following codeplex project, I would greatly appreciate it:

virtualwrappanel.codeplex/workitem/1

谢谢!

问题摘要:

我最近尝试使用此项目中的虚拟包装面板,并且遇到了错误。

I've recently tried using the virtualizing wrappanel from this project and have encountered a bug.

复制步骤:

  • 创建列表框。
  • 将虚拟包装面板设置为列表框面板模板中的itemhost。
  • 将列表框的itemsource绑定到可观察的集合中。
  • Create listbox.
  • Set the virtualizing wrappanel as the itemhost in a listboxpanel template.
  • Bind the itemsource of the listbox to an observable collection.
  • Remove an item from the backing observable collection.
  • Debug.Assert失败(Debug.Assert(child == _children [childIndex], MeasureOverride中的生成了错误的子级);),并且继续执行会导致Cleanup方法中出现空异常[请参见随附的屏幕截图]。

    The Debug.Assert fails (Debug.Assert(child == _children[childIndex], "Wrong child was generated");) in MeasureOverride, and continued execution results in a null exception in the Cleanup method [see attached screenshot].

    请让我知道您是否能够纠正此问题。

    Please let me know if you are able to correct this.

    谢谢,

    AO

    代码:

    virtualwrappanel.codeplex/SourceControl/list/changesets#

    替代文字virtualwrappanel.codeplex/Project/Download/AttachmentDownload.ashx?ProjectName=virtualwrappanel&WorkItemId=1&FileAttachmentId=138959

    推荐答案

    OnItemsChanged方法需要正确处理args参数。有关更多信息,请参见此问题。复制该问题的代码,您需要像这样更新OnItemsChanged:

    The OnItemsChanged method needs to properly handle the args parameters. Please see this question for more information. Copying the code from that question, you would need to update OnItemsChanged like so:

    protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args) { base.OnItemsChanged(sender, args); _abstractPanel = null; ResetScrollInfo(); // ...ADD THIS... switch (args.Action) { case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Replace: RemoveInternalChildRange(args.Position.Index, args.ItemUICount); break; case NotifyCollectionChangedAction.Move: RemoveInternalChildRange(args.OldPosition.Index, args.ItemUICount); break; } }

    更多推荐

    虚拟化WPF包装面板问题

    本文发布于:2023-11-12 17:11:47,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1582056.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:面板   WPF

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!