reactiveui

ReactiveUI 6 Async Command Not Running on Background Thread in WPF app

微笑、不失礼 提交于 2019-12-01 06:40:55
ViewModel public class MyViewModel:ReactiveObject, IRoutableViewModel{ private ReactiveList<string> _appExtensions; public MyViewModel(IScreen screen){ HostScreen = screen; AppExtensions = new ReactiveList<string>(); GetApplicationExtensions = ReactiveCommand.CreateAsyncTask(x => _schemaService.GetApplicationExtensions()); // returns a Task<IEnumerable<string>> GetApplicationExtensions .ObserveOn(RxApp.MainThreadScheduler) .SubscribeOn(RxApp.TaskpoolScheduler) .Subscribe(p => { using (_appExtensions.SuppressChangeNotifications()) { _appExtensions.Clear(); _appExtensions.AddRange(p); } });

Bind data inside ListBox using code-behind in ReactiveUI

若如初见. 提交于 2019-12-01 05:12:00
问题 I have WPF listbox: <ListBox Name="FileDownloads" SelectionMode="Extended"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Name="Url" Text="{Binding Url}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> I like the ability to bind ListBox by name from code behind using: this.OneWayBind(ViewModel, vm => vm.DownloadManager.FileDownloads, v => v.FileDownloads.ItemsSource); Having binding in code-behind helps with refactoring. Is there any way to bind Url texbox inside the listbox using

ReactiveUI: Using CanExecute with a ReactiveCommand

一曲冷凌霜 提交于 2019-12-01 00:20:35
I'm starting to work with the ReactiveUI framework on a Silverlight project and need some help working with ReactiveCommands. In my view model, I have something that looks roughly like this (this is just a simplified example): public class MyViewModel : ReactiveObject { private int MaxRecords = 5; public ReactiveCommand AddNewRecord { get; protected set; } private ObservableCollection<string> _myCollection = new ObservableCollection<string>(); public ObservableCollection<string> MyCollection { get { return _myCollection; } set { _myCollection = value; raiseCollectionChanged("MyCollection"); }

ReactiveUI: Using CanExecute with a ReactiveCommand

泪湿孤枕 提交于 2019-11-30 19:38:44
问题 I'm starting to work with the ReactiveUI framework on a Silverlight project and need some help working with ReactiveCommands. In my view model, I have something that looks roughly like this (this is just a simplified example): public class MyViewModel : ReactiveObject { private int MaxRecords = 5; public ReactiveCommand AddNewRecord { get; protected set; } private ObservableCollection<string> _myCollection = new ObservableCollection<string>(); public ObservableCollection<string> MyCollection

ReactiveUI, View/ViewModel injection and DI in general

主宰稳场 提交于 2019-11-29 21:58:18
Lately I've trying to get myself into the new age of UI development and discovered ReactiveUI. I love its declarative nature. I wanted to make a complete switch, so I tried to understand how are things made in this new world of ReactiveUI. I choose ReactiveUI because I've seen that is maintained by a very clever guy (Paul C. Betts). I'm very new to it and I will likely be flooding StackOverflow with questions about it because I has a huge power and I think it deserves to be learnt and mastered . Let's get into the details: I've always used View-First. I'm a veteran user of the Cinch Framework

ReactiveUI exception handling

烂漫一生 提交于 2019-11-29 21:55:31
I've looked around at a number of the ReactiveUI samples, but I can't see a good simple example of how to handle exceptions, where a message should be displayed to the user. (If there is a good example can somebody point me to it?). My first question is how to handle an exception with ReactiveCommand and ToProperty. For example, I have the following code: public class MainWindowViewModel : ReactiveObject { public ReactiveCommand CalculateTheAnswer { get; set; } public MainWindowViewModel() { CalculateTheAnswer = new ReactiveCommand(); CalculateTheAnswer .SelectMany(_ => AnswerCalculator())

What are the distinctions between the various WhenAny methods in Reactive UI

∥☆過路亽.° 提交于 2019-11-29 05:18:07
问题 There are several extension methods in Reactive UI for getting observables for property changes. I think I understand WhenAny and WhenAnyValue . WhenAny is for a series of property change notifications where you want the metadata of which object and property had the change, while WhenAnyValue is for when you really just want the stream of changed values. First of all, is that an accurate assessment? What about WhenAnyDynamic , WhenAnyObservable , and ObservableForProperty ? I can't really