Created
December 5, 2013 05:28
-
-
Save dtchepak/7800565 to your computer and use it in GitHub Desktop.
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 ObservableItems<T> : INotifyPropertyChanged | |
{ | |
private IEnumerable<T> _items; | |
public ObservableItems(IObservable<IEnumerable<T>> source, IEnumerable<T> initialValue) | |
{ | |
Items = initialValue; | |
source | |
.ObserveOnDispatcher() | |
.Subscribe(x => Items = x); | |
} | |
public IEnumerable<T> Items | |
{ | |
get { return _items; } | |
private set { _items = value; OnPropertyChanged(); } | |
} | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) | |
{ | |
var handler = PropertyChanged; | |
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment