MVVM - RaisePropertyChanged turning code into a mess

前端 未结 5 2014
萌比男神i
萌比男神i 2021-01-12 00:08

New to MVVM so please excuse my ignorance.

I THINK i\'m using it right but I find my ViewModel has too many of these:

RaisePropertyChanged(\"SomeProp         


        
5条回答
  •  春和景丽
    2021-01-12 00:14

    This will help: "Kind Of Magic" Effortless INotifyPropertyChanged

    [http://visualstudiogallery.msdn.microsoft.com/d5cd6aa1-57a5-4aaa-a2be-969c6db7f88a][1]

    as an example for adding it to one property:

    [Magic] 
    public string Name { get { return _name; } set { _name = value; } } 
    string _name;
    

    Another example for adding it to all the class properties:

    [Magic] 
    public class MyViewModel: INotifyPropertyChanged 
    { 
      public string Name { get; set; } 
      public string LastName { get; set; } 
      ..... 
    }
    

提交回复
热议问题