Skip to content

Instantly share code, notes, and snippets.

@TheAngryByrd
Created September 18, 2015 21:18
Show Gist options
  • Select an option

  • Save TheAngryByrd/a57fe69dcb74835fcf79 to your computer and use it in GitHub Desktop.

Select an option

Save TheAngryByrd/a57fe69dcb74835fcf79 to your computer and use it in GitHub Desktop.
ChildEvents
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);
}
}
@kevinkuebler

Copy link
Copy Markdown

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(...) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment