Windows phone 7 WP7上的ListBox出现问题-System.Windows.Markup.XamlParseException
各位。 我有一个列表框。当我尝试显示61项时,它运行正常。 但是当它达到62个或更多的时候,应用程序就会与Windows phone 7 WP7上的ListBox出现问题-System.Windows.Markup.XamlParseException,windows-phone-7,listbox,xamlparseexception,Windows Phone 7,Listbox,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
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.ItemsPanel更改为StackPanel,而不是VirtualzingStackPanel。这将允许可变高度的项目,但有一个折衷办法,因为如果列表中有很多项目,则会增加启动时间和内存使用。如何将项目添加到列表框?您是在代码中还是直接在标记中添加它们?如果要在标记中添加它们,能否发布最后几项的标记?我在代码中添加项。通过ItemsSource属性您应该将项目添加到分配给
ItemsSource
属性的ObservableCollection
,而不是直接添加到ItemsSource
属性本身。您可以发布一些代码(XAML和C#)吗?