Search code examples
c#mvvmxamarin.formsprismfody

Xamarin Prism Model to ViewModel Fody


how do I Intercept From Model to ViewModel using Fody ?

I tried putting this in my ViewModel but nothing happens, Am I missing something ? I'm Using Xamarin Forms, Prism Model

   public class Question : INotifyPropertyChanged
    {
        public bool IsValid { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            Debug.WriteLine("This Works Here :) ");
            var propertyChanged = PropertyChanged;
            if (propertyChanged != null)
            {
                propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

ViewModel

public class MainPageViewModel : INavigationAware, INotifyPropertyChanged{
        public virtual void OnPropertyChanged(string propertyName)
        {
            Debug.WriteLine("It Does not reach here :( ");
        }

        public static void Intercept(object target, Action onPropertyChangedAction, string propertyName)
        {
            Debug.WriteLine("It Does not reach here too :( ");
            onPropertyChangedAction();
        }
}

Do I need to use PropertyChangedNotificationInterceptor ? How do I implement it in my View-Model , Any advice would be awesome

[UPDATE]

Sample of Repo here


Solution

  • in fody property changed is called as easy as this :

    public string Text{ get; set; }
    public void OnTextChanged()
    {
    }