Created
August 31, 2013 05:35
-
-
Save kirkshoop/6396398 to your computer and use it in GitHub Desktop.
Excerpt from https://github.com/kirkshoop/rxaccelerometer showing how to create a ReactiveCommand and bind it to a Xaml button
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
typedef rxrt::EventPattern<Object^, Windows::UI::Xaml::RoutedEventArgs^> RoutedEventPattern; | |
// start out disabled | |
enabled = std::make_shared<rx::BehaviorSubject<bool>>(false); | |
// use enabled to control canExecute | |
disable = std::make_shared < rxrt::ReactiveCommand < RoutedEventPattern> >(observable(enabled)); | |
from(observable(disable)) | |
// stay on the ui thread | |
.subscribe([this](RoutedEventPattern) | |
// on click | |
{ | |
... | |
// now the scenario is disabled | |
this->enabled->OnNext(false); | |
}); | |
rxrt::BindCommand(ScenarioDisableButton, disable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment