PRISM 下实现 DataGrid 数据源数据修改后 能动态变化

今天在折腾项目的时候,发现当我执行了删除数据后 前台的 DataGrid 数据并没有变化,即使我重新读取了数据,后来才知道得通过 “Microsoft.Practices.Prism.ViewModel” 下的方法 "NotificationObject" 实现监控数据是否变化,然后反应在 View 层上。

具体实现代码如下:

    [Export(typeof(TestCaseListViewModel))]
    public class TestCaseListViewModel : NotificationObject
    {
        private ICollectionView testCases;
        public ICollectionView TestCases
        {
            get { return this.testCases; }
            set
            {
                this.testCases = value;
                //重点在这里
                this.RaisePropertyChanged("TestCases");
            }
        }

猜你喜欢

转载自lstoryc.iteye.com/blog/2006981