开发者

SendPropertyChanged of public field with private field

I开发者_开发百科 would like to send a property changed event of the public property everytime the private member is set. How would I do this?

private string _imageName;

public string ImageName
{
    get
    {
        return _imageName;
    }
    set
    {
        _imageName = value;
        SendPropertyChanged("ImageName");
    }
}

protected virtual void SendPropertyChanged(string propertyName)
{
    if ((this.PropertyChanged != null))
    {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}


Use the property instead. Thats, what it's for

Or if you must, call SendPropertyChanged("ImageName") whenever you change the private field.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜