WPF-虚拟化WrapPanel [英] WPF - Virtualising WrapPanel

查看:257
本文介绍了WPF-虚拟化WrapPanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以在WPF应用程序中使用可运行的虚拟化WrapPanel吗?

does anyone have a functioning virtualising WrapPanel I can use in a WPF application?

我已经在 http://virtualwrappanel.codeplex.com/下载并尝试了该实现.但是,出现以下异常:

I have downloaded and tried the implementation at http://virtualwrappanel.codeplex.com/. However, I get the following exception:

元素'MyNamespace.VirtualizingWrapPanel'的布局尺寸替代将不返回PositiveInfinity作为其DesiredSize,即使将Infinity作为可用大小传递."

"Layout measurement override of element 'MyNamespace.VirtualizingWrapPanel' should not return PositiveInfinity as its DesiredSize, even if Infinity is passed in as available size."

这是在尝试将包装面板应用于ListBox时

This is when trying to apply the wrappanel to a ListBox

推荐答案

这可能是一个错误,您可能可以自己修复.查找MeasureOverride方法.似乎总是将availableSize夹返回返回给该方法.作为例外,在包含double.PositiveInfinity的情况下不能返回availableSize.所以试试这个:

This is probably a bug that you might be able to fix yourself. Look for the MeasureOverride method. It always seem to return the availableSize wich was passed to the method. As the exception states you must not return availableSize when it contains double.PositiveInfinity. So try this:

if(availableSize.Width == double.PositiveInfinity || availableSize.Height == double.PositiveInfinity)
{
    return Size.Empty;
}

// all the measureoverride code comes here

return availableSize;

我没有详细研究实现.但是谁知道呢,如果面板没有保存MeasureOverrideArrangeOverride之间的状态,您也许可以解决这个问题(如果实施得当的话,它就不应该保存).

I haven't looked at the implementation in details. But who knows, you might be able to get a away with this if the panel doesn't save state between MeasureOverride and ArrangeOverride (wich it shouldn't if it is well implemented).

这篇关于WPF-虚拟化WrapPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆