C# Xamarin棱镜模型到ViewModel Fody
如何使用从模型到ViewModel进行截取 我试着把它放在我的ViewModel中,但什么都没发生,我是不是遗漏了什么? 我使用的是Xamarin表单,Prism 型号C# Xamarin棱镜模型到ViewModel Fody,c#,mvvm,xamarin.forms,prism,fody,C#,Mvvm,Xamarin.forms,Prism,Fody,如何使用从模型到ViewModel进行截取 我试着把它放在我的ViewModel中,但什么都没发生,我是不是遗漏了什么? 我使用的是Xamarin表单,Prism 型号 public class Question : INotifyPropertyChanged { public bool IsValid { get; set; } public event PropertyChangedEventHandler PropertyChanged;
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));
}
}
}
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();
}
}
视图模型
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));
}
}
}
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();
}
}
我是否需要使用属性ChangedNotificationInterceptor?我该如何在我的视图模型中实现它,任何建议都会非常棒
[更新]
在fody中,属性更改被称为如下所示:
public string Text{ get; set; }
public void OnTextChanged()
{
}
在fody中,属性更改的调用非常简单,如下所示:
public string Text{ get; set; }
public void OnTextChanged()
{
}
确保您的目标平台项目中有一个Weavers.xml。我在前面的评论中有一个输入错误,xml文件名应该是:“FodyWeavers.xml”。可能与@EvZ有关,谢谢,但不是这样,我在问题中添加了一个示例repo确保目标平台项目中有一个Weavers.xml。我在前面的评论中有一个输入错误,xml文件名应该是:“FodyWeavers.xml”。可能与@EvZ Thanks有关,但不是这样,我在问题中添加了一个回购示例谢谢,在我还是一个Noobie时创建了这个问题:),我从未意识到你必须使模式本身可绑定谢谢,在我还是Noobie时创建了这个问题:),我从未意识到你必须使模式本身可绑定