2015-09-07 42 views
0

我在嘗試更新Devexpress TreeListItemSource。它似乎工作,我第一次按下我的按鈕,但它不工作了...是否還有其他我必須更新以更改ItemSource正在更新中TreeList ItemSource

代碼

window.randButton.Click += delegate 
      { 
       string st = window.nList.CurrentCellValue.ToString(); 
       System.Diagnostics.Debug.WriteLine("Called: "+st); 

       try { 
        window.treeList.ItemsSource = null; 
        window.treeList.ItemsSource = drawOrderBook(currCycle, st); 
        // currCylce is static data 
        // drawOrderBook computes what to display based on the filer st 
       } 
       catch(Exception er) { System.Diagnostics.Debug.WriteLine(er.ToString()); } 


      }; 

回答

1

我曾與DevExpress電網類似的問題。

根據他們的指導方針/技術支持,您必須在數據鏈接修改/更改時調用RefreshDataSource方法。

所以你的代碼應該是這樣的。

window.randButton.Click += delegate 
{ 
    string st = window.nList.CurrentCellValue.ToString(); 
    System.Diagnostics.Debug.WriteLine("Called: "+st); 

    try 
    { 
     window.treeList.ItemsSource = null; 
     window.treeList.ItemsSource = drawOrderBook(currCycle, st); 
     window.treeList.RefreshDataSource(); 
     // currCylce is static data 
     // drawOrderBook computes what to display based on the filer st 
    } 
    catch(Exception er) { System.Diagnostics.Debug.WriteLine(er.ToString()); } 

};