Tuesday, 15 May 2012

c# - Getting prior value on change of property using ReactiveUI in WPF MVVM -


I am using a reactiv UI for an MVVM WPF project, and I know when a property changes

  • The new value (i.e. change)
  • I have a view modal ( Receiving from Reactive Object ) with a property declared on it:

      Personal accountholder type _accountHolderType; Public Account Holder Type Account Holder Type {Receive {Return _accountHolderType; } Set {this.RaiseAndSetIfChanged (ref _accountHolderType, value); }}  

    In the manufacturer, I am trying to do the following:

      this.WhenAnyValue (vm => vm.AccountHolderType). Subscribe (Subscribe (Old, Carr) = & gt; {/} do something here));  

    But there is no such surcharge in any value method, and the reactive documentation is quite lacking.

    I Access a simple when any value :

      this.WhenAnyValue (vm = & Gt; vm.AccountHolderType). Subscribe (val = & gt; {// do something here}};  

    This allows me to follow the changes and gets the latest changes, but I need the first price .

    I know that I can implement it in simple form such as:

      public account holder type accountholder type {get {//} set {var Prev = _accountHolderType; _accountHolderType = value; // old and new values ​​work with DoSomething (formerly, value);}}  

    but The project is using the reactative UI, I probably want to be in the form of "responsive-y".

    < P> About:

      this.WhenAnyValue (vm = & gt; vm.AccountHolderType). Buffer (2, 1). Select (b = & gt; New {pre = Subscribe [B] [0], current = b [1]}) (t => logic by using the previous and new value for account holder type);  

    I think you have forgotten this straight forward function.


    No comments:

    Post a Comment