Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wpf mvvm crud
Message
From
28/02/2019 11:24:05
John Baird
Coatesville, Pennsylvania, United States
 
 
To
28/02/2019 06:41:33
General information
Forum:
C#
Category:
Forms
Title:
Miscellaneous
Thread ID:
01666655
Message ID:
01666842
Views:
54
>Hi John,
>
>Yes, I'm focusing on this methodology.
>
>One thing confused me:
>where it should be RaisePropertyChanged("...") in a Model or in a ViewModel?
>
>In the example I sent, contains one Model and one ViewModel, but RaisePropertyChanged("...") is in the model. Is that right way?
>In this case, the update works properly.
>
>Thanks

This is an example of how I use it. I have a base viewmodel with lots of functionality, which I have stripped from this because its just my way of doing things. The call to OnPropertyChange() in the viewmodel, passes the name of the property to the baseviewmodel and raises the event.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace MyProg.ViewModels
{
    public class BaseViewModel : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged([CallerMemberName] string name = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }
}
  
namespace MyProg
{
    public class LoginViewModel : BaseViewModel
    {
     
        #region
        private string verifyCode;
        public string VerifyCode
        {
            get
            {
                return verifyCode;
            }
            set
            {
                verifyCode = value;
                OnPropertyChanged();
            }
        }
      #endregion
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform