‘不能分配给 – 只读’还有一个二传手吗?
我得到一个(对我而言)非常奇怪的参数exception。
当调用this.MainViewModel.MyObject = new MyObject(..some parameters here..);
,我得到property or indexer 'IMainViewModel.MyObject' cannot be assigned to -- it is read only
。 我一直在努力寻找有类似问题的人,但每次答案都是“你有一个二传手吗?”。 是的,我确实有一个二传手。 是的,我的财产是公开的。 我很困惑为什么它在这里投入适合。
我想写的属性是;
public Object MyObject { get { return this.myObject; } set { this.myObject = value; this.RaisePropertyChanged(); this.eventAggregator.GetEvent().Publish(this.MyObject); } }
我不知道我错过了哪些将MyObject属性限定为readonly ..?