'cannot be assigned to — is read only' yet has a setter?

﹥>﹥吖頭↗ 提交于 2020-01-04 03:15:24

问题


I'm getting a (to me) very weird looking argument exception.

When calling this.MainViewModel.MyObject = new MyObject(..some parameters here..);, I get property or indexer 'IMainViewModel.MyObject' cannot be assigned to -- it is read only. I've been trying to find people with similar questions but everytime the answer is 'do you have a setter?'. Yes, I do have a setter. Yes, my property is public. I'm very confused as to why it is throwing a fit here.

The property I'm trying to write to is;

public Object MyObject
{
    get { return this.myObject; }
    set
    {
        this.myObject = value;
        this.RaisePropertyChanged();
        this.eventAggregator.GetEvent<SetMyObjectEvent>().Publish(this.MyObject);
    }
}

I don't know what I'm missing that qualifies the MyObject property as readonly .. ?

来源:https://stackoverflow.com/questions/39450154/cannot-be-assigned-to-is-read-only-yet-has-a-setter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!