-
-
Save ghuntley/b036fe5ba354153e704b to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// in the View constructor | |
this.WhenActivated(d => | |
{ | |
d(MyListView.Events().SelectionChanged.Subscribe(args => | |
{ | |
foreach (var item in args.AddedItems.Cast<MyModelType>()) | |
{ | |
item.IsSelected = true; | |
} | |
foreach (var item in args.RemovedItems.Cast<MyModelType>()) | |
{ | |
item.IsSelected = false; | |
} | |
}); | |
}); | |
// | |
// in the ViewModel constructor | |
Models = new ReactiveList<MyModelType>(/* initialize... */); | |
SelectedModels = Models.CreateDerivedCollection(x => x, model => model.IsSelected); | |
// | |
// definition of the model object for completeness | |
public class MyModelType : ReactiveObject | |
{ | |
private bool _isSelected; | |
public bool IsSelected | |
{ | |
get { return _isSelected; } | |
set { this.RaiseAndSetIfChanged(ref _isSelected, value); } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment