Created
September 18, 2015 21:18
-
-
Save TheAngryByrd/a57fe69dcb74835fcf79 to your computer and use it in GitHub Desktop.
ChildEvents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Passenger : ReactiveObject | |
| { | |
| public IObservable<bool> SelectedObs; | |
| public Passenger() | |
| { | |
| SelectedObs = this.WhenAny(x => x.IsSelected, x => x.Value); | |
| } | |
| bool _isSelected; | |
| public bool IsSelected | |
| { | |
| get { return _isSelected; } | |
| set { this.RaiseAndSetIfChanged(ref _isSelected, value); } | |
| } | |
| } | |
| public class MainViewModel : ReactiveObject | |
| { | |
| readonly ObservableAsPropertyHelper<List<Passenger>> passengers; | |
| public List<Passenger> Passengers | |
| { | |
| get { return passengers.Value; } | |
| } | |
| public MainViewModel() | |
| { | |
| var abc = this.WhenAny(x => x.Passengers, x => x.Value).SelectMany(x => x.ToObservable()).SelectMany(x => x.SelectedObs); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool, thanks! This didn't quite give me my original goal of having a ReactiveDerivedList of the selected passengers in the main vm, but I was able to use it to get to where I wanted to go. :-)
Question though ... why the use of WhenAny(..., x => x.Value) instead of WhenAnyValue(...) ?