2011-06-26 14 views
1

みんな。 私はlistBoxを持っています。私は61の項目を表示しようとすると - それは正常に実行されます。それが62の以上だとき は、しかし - それはランダムな瞬間に抜ける..私は見当もつかない - アプリは、それが何をすることができListBoxのWP7での問題 - System.Windows.Markup.XamlParseExceptionが発生しました

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

コードに項目を追加します。 via ItemsSourceプロパティ – Monochromie

+1

'ItemsSource'プロパティに割り当てられている' ObservableCollection 'にアイテムを追加する必要があります。直接' ItemsSource'プロパティ自体には追加しないでください。 –

答えて

0

リストボックスに可変高さの項目がある可能性があります。 ListBox.ItemsPanelをVirtualizingStackPanelの代わりにStackPanelに変更してみることもできます。これにより可変高さの項目が許可されますが、リストに多くの項目がある場合は、起動時間とメモリ使用量を増やすため、トレードオフがあります。

関連する問題