Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in the viewmodel
- class MainViewModel : ReactiveObject
- {
- public ReactiveUI.ReactiveCommand<Unit, Unit> MyReactiveCommand { get; }
- public MainViewModel()
- {
- MyReactiveCommand = ReactiveCommand.Create(() => { MessageBox.Show("Hello"); }, outputScheduler: RxApp.MainThreadScheduler);
- }
- }
- //in the view xaml
- <Window.DataContext>
- <local:MainViewModel/>
- </Window.DataContext>
- <Grid>
- <WrapPanel HorizontalAlignment = "Left">
- <Button Content="button" Command="{Binding MyReactiveCommand}"/>
- </WrapPanel>
- </Grid>
- public class MainViewModel : ReactiveObject
- {
- public ReactiveCommand<Unit, Unit> MyReactiveCommand { get; }
- public MainViewModel()
- {
- MyReactiveCommand = ReactiveCommand.CreateFromObservable(DoSometing);
- MyReactiveCommand.Subscribe(x => { MessageBox.Show("Hello"); });
- }
- public IObservable<Unit> DoSometing()
- {
- return Observable.Start(() => { });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement