Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wpf mvvm crud
Message
De
28/02/2019 11:24:05
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
28/02/2019 06:41:33
Information générale
Forum:
C#
Catégorie:
Formulaires
Titre:
Divers
Thread ID:
01666655
Message ID:
01666842
Vues:
55
>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
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform