using a Code Snippet for INotifyPropertyChanged

前端 未结 5 590
再見小時候
再見小時候 2020-12-17 23:46

I found this code snippet for INotifyPropertyChanged

But it shows the code like this :

\"INotifyProperty

5条回答
  •  执笔经年
    2020-12-18 00:34

    I don't think this can be done with native code snippets feature provided by Visual Studio.

    Personally I use Resharper which makes it possible. It can turn code I write like

    public string Name { get; set; }
    

    into

    private string _name;
    public string Name
    {
        get { return _name; }
        set
        {
            if(value == _name)
                return;
            _name = value;
            OnPropertyChanged("Name");
        }
    }
    

    It even generates the OnPropertyChanged() method for you.

提交回复
热议问题