更新TreeList ItemSource

时间:2015-09-07 03:28:00

标签: c# wpf devexpress

我正在尝试更新Devexpress TreeList ItemSource。它似乎在我第一次按下我的按钮时起作用,但是它不再起作用了......我还需要更新其他内容才能更改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 个答案:

答案 0 :(得分: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());  }

};