1

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

LeRoy
  • 4,189
  • 2
  • 35
  • 46
  • Ensure that you have a Weavers.xml in your targeting platform projects with in it. – EvZ Jan 31 '18 at 21:58
  • I have a typo in the previous comment, the xml file name should be: "FodyWeavers.xml". Might be related to https://github.com/Fody/Fody/issues/363 – EvZ Jan 31 '18 at 23:06
  • @EvZ Thanks but that not it, I added a sample repo in my question – LeRoy Feb 01 '18 at 06:47

1 Answers1

2

in fody property changed is called as easy as this :

public string Text{ get; set; }
public void OnTextChanged()
{
}
  • Thanks, Created this question when I was still a Noobie :) , I never realised that you had to make the Modal itself Bindable – LeRoy Sep 26 '18 at 04:49