大家。 我有一个listBox。当我尝试显示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结束,看到最后一个元素,当我向后滚动时 - 它会抛出错误。
答案 0 :(得分:0)
您很可能在列表框中有可变高度的项目。您可以尝试将ListBox.ItemsPanel更改为StackPanel而不是VirtualizingStackPanel。这将允许可变高度的项目,但有一个权衡,因为如果列表中有很多项目,那么你将增加启动时间和内存使用。