Binding 字段绑定与弱引用

Binding 字段绑定与弱引用,binding,mvvmcross,weak-references,Binding,Mvvmcross,Weak References,我愿意使用notify property change mecanism的INC版本,它比property+Field+RaiseProperty Changed版本更简洁 但是,假设我有这个ViewModel: public abstract class PageViewModel : MvxViewModel { /// <summary> /// The is loading /// </summary> public rea

我愿意使用notify property change mecanism的INC版本,它比property+Field+RaiseProperty Changed版本更简洁

但是,假设我有这个ViewModel:

public abstract class PageViewModel : MvxViewModel
{
    /// <summary>
    ///     The is loading
    /// </summary>
    public readonly INC<bool> IsLoading = new NC<bool>();

    /// <summary>
    ///     The subtitle
    /// </summary>
    public readonly INC<string> Subtitle = new NC<string>();

    /// <summary>
    ///     The title
    /// </summary>
    public readonly INC<string> Title = new NC<string>();
不过,在第二时间,如果WeakSubscribe能够这样做,那就太好了:

 viewModel.Title.WeakSubscri...
嗯,奇怪,我没有自动完成的功能

让我们看看MvxWeakSubscriptionExtensionMethods:

public static class MvxWeakSubscriptionExtensionMethods
{
    public static MvxNotifyPropertyChangedEventSubscription WeakSubscribe(this INotifyPropertyChanged source, EventHandler<PropertyChangedEventArgs> eventHandler)
    {
         return new MvxNotifyPropertyChangedEventSubscription(source, eventHandler);
    }

    public static MvxValueEventSubscription<T> WeakSubscribe<T>(this EventInfo eventInfo, object source, EventHandler<MvxValueEventArgs<T>> eventHandler)
    {
         return new MvxValueEventSubscription<T>(source, eventInfo, eventHandler);
    }
现在是公司


那么,有没有办法弱订阅INC属性?

插件本身使用弱引用进行绑定,使用:

  IDisposable _subscription = NotifyChangeEventInfo.WeakSubscribe(_notifyChange, NotifyChangeOnChanged); 
其中NotifyChangeOnChanged具有签名:

  protected abstract void NotifyChangeOnChanged(object sender, EventArgs eventArgs); 

  IDisposable _subscription = NotifyChangeEventInfo.WeakSubscribe(_notifyChange, NotifyChangeOnChanged); 
  protected abstract void NotifyChangeOnChanged(object sender, EventArgs eventArgs);