Skip to content

Instantly share code, notes, and snippets.

@philcleveland
Created November 5, 2013 19:40
Show Gist options
  • Save philcleveland/7324883 to your computer and use it in GitHub Desktop.
Save philcleveland/7324883 to your computer and use it in GitHub Desktop.
SearchViewModel with ReactiveUI
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