加载时崩溃LongListSelector
我有一个很长的列表选择器,其中我显示按日期排序的数据。 我现在面临的问题是,成功的列表为首次载入时间,但回来的页面方含从细节页面longlistselctor后,应用程序与以下异常崩溃: System.NullReferenceException was unhandled Message=NullReferenceException StackTrace: at Microsoft.Phone.Controls.LongListSelector.Balance() at Microsoft.Phone.Controls.LongListSelector.LongListSelector_LayoutUpdated(Object sender, EventArgs e) at System.Windows.FrameworkElement.OnLayoutUpdated(Object sender, EventArgs e) at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)
加载时崩溃LongListSelector
我因为这种事情发生了,他甚至无法追查。 列表填充为:
currentAudioList = DiaryDBController.DBController.GetDiaryRecordsWithAudio();
var DiaryAudioRecordsByDate = from rec in currentAudioList
group rec by rec.CreationDate into r
orderby r.Key
select new Group<DatabaseClasses.DiaryRecord>(r.Key, r);
try
{
this.AudioGroupListSelector.ItemsSource = DiaryAudioRecordsByDate;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
任何帮助将不胜感激。 谢谢。
我遇到了同样的问题,在Codeplex上报告了here以及可能的解决方法。
它看起来像问题可以通过从改变LongListSelector.Balance()方法的第一行是固定的:
if(!IsReady() || _flattenedItems.Count == 0)
到
if(!IsReady() || _flattenedItems == null || _flattenedItems.Count == 0)