WP7 上的 ListBox 出现问题 - 发生 System.Windows.Markup.XamlParseException
每个人。 我有一个列表框。当我尝试显示 61 个项目时 - 它运行正常。 但是当它达到 62 个或更多时 - 应用程序会随着
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)
at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
它是什么而掉落 - 我不知道.. 它会在随机的时刻掉落。我可以将 listBox 滚动到末尾,查看最后一个元素,当我向后滚动时 - 它会抛出错误。
everyone.
I got a listBox. When I try to show 61 items - it runs OK.
But when it's 62 or more - apps falls with
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
LineNumber=0
LinePosition=0
StackTrace:
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(UIElement child, Size layoutSlotSize)
at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
What can it be - I have no clue.. It falls out in a random moment. I can scroll listBox to end, see last element, and when I scroll back - it throw error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的列表框中很可能有可变高度的项目。您可以尝试将 ListBox.ItemsPanel 更改为 StackPanel 而不是 VirtualizingStackPanel。这将允许可变高度的项目,但需要权衡,因为如果列表中有很多项目,那么您将增加启动时间和内存使用量。
You most likely have variable-height items in your listbox. You can try changing the the ListBox.ItemsPanel to be a StackPanel instead of the VirtualizingStackPanel. This will allow variable height items, but there is a tradeoff because if you have a lot of items in the list then you are going to increase startup time and memory usage.