Created
November 5, 2013 19:40
-
-
Save philcleveland/7324883 to your computer and use it in GitHub Desktop.
SearchViewModel with ReactiveUI
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
using ReactiveUI; | |
using System.Threading.Tasks; | |
using System.Windows.Input; | |
using TwitterFeedAPI; | |
namespace FeedManagement.WPF.Search | |
{ | |
public class SearchViewModel : ReactiveObject, ISearchViewModel | |
{ | |
public IScreen HostScreen { get; protected set; } | |
public ICommand SearchCommand { get; private set; } | |
public Twitter _twitterAPI = new Twitter(); | |
public SearchViewModel(IScreen screen) | |
{ | |
HostScreen = screen; | |
SearchCommand = new ReactiveCommand(); | |
(SearchCommand as ReactiveCommand).RegisterAsyncTask(t => | |
{ | |
return Task.Factory.StartNew(() => | |
{ | |
SearchResult = _twitterAPI.SearchFor(SearchText); | |
}); | |
}); | |
} | |
private string _SearchResult; | |
public string SearchResult | |
{ | |
get { return _SearchResult; } | |
set { this.RaiseAndSetIfChanged(ref _SearchResult, value); } | |
} | |
public string SearchText { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment