2011-04-11 99 views
1

我有一個很長的列表選擇器,其中我顯示按日期排序的數據。 我現在面臨的問題是,成功的列表爲首次載入時間,但回來的頁面方含從細節頁面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); 
     } 

任何幫助將不勝感激。 謝謝。

回答

2

我遇到了同樣的問題,在Codeplex上報告了here以及可能的解決方法。

它看起來像問題可以通過從改變LongListSelector.Balance()方法的第一行是固定的:

if(!IsReady() || _flattenedItems.Count == 0) 

if(!IsReady() || _flattenedItems == null || _flattenedItems.Count == 0)