gpt4 book ai didi

c# - Xamarin Prism模型到ViewModel Fody

转载 作者:行者123 更新时间:2023-12-03 11:02:48 27 4
gpt4 key购买 nike

如何使用Fody拦截从模型到ViewModel?

我尝试将其放入ViewModel中,但没有任何 react ,我是否缺少任何东西?
我正在使用Xamarin形式, Prism
模型

   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();
}
}

我需要使用 PropertyChangedNotificationInterceptor 吗?我如何在View-Model中实现它,任何建议都很棒

[更新]

Sample of Repo here

最佳答案

在fody属性中,更改就像这样简单:

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

关于c# - Xamarin Prism模型到ViewModel Fody,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48550005/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com