reactiveui

How do I make a direct call to ReactiveCommand.Execute() in ReactiveUI 7 correct?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 00:54:01
问题 I'm trying to convert my project from ReactiveUI 6.5 to version 7. In the old version I called // var command = ReactiveCommand.Create...; // ... if(command.CanExecute(null)) command.Execute(null); in order to execute a command from my code behind. Now the CanExecute method is no longer available and replaced with a property of IObservable<bool> . Is the CanExecute Observable automatically called if I just make a call to Execute().Subscribe() or must I call it explicitly? For now I replaced

ReactiveUI The calling thread cannot access this object because a different thread owns it

雨燕双飞 提交于 2019-12-06 15:58:32
If I use a binding in code behind, getting an error after click at change IsBusy "The calling thread cannot access this object because a different thread owns it" xaml: <Button x:Name="AsyncCommand" Height="20" Content="PushAsync"/> <ProgressBar x:Name="IsBusy" Height="20"/> cs: this.Bind(ViewModel, x => x.IsBusy, x => x.IsBusy.IsIndeterminate); this.BindCommand(ViewModel, x => x.AsyncCommand, x => x.AsyncCommand); viewmodel: public class TestViewModel : ReactiveObject { public TestViewModel() { AsyncCommand = new ReactiveAsyncCommand(); AsyncCommand .RegisterAsyncFunction(x => { IsBusy = true

How to Bind data to a Custom ListView with Xamarin Android with Reactive UI

久未见 提交于 2019-12-06 13:39:02
I am using Xamarin Android with Reactive UI and Not using Xamarin Forms. I have a Custom ListView(I have defined it's layout as xaml). I have no idea how to bind this control into a observableCollection in ViewModel using OneWayBind method in the activity class. I wrote it as, this.OneWayBind(ViewModel, x => x.OutletListing, x => x.List).DisposeWith(SubscriptionDisposables); But gives, System.ArgumentException: Can't convert System.Collections.ObjectModel.ObservableCollection1 to Android.Widget.ListView. To fix this, register a IBindingTypeConverter I saw in tutorials Xamarin Forms has used

How do I merge several observables using WhenAny(…) in ReactiveUI?

泄露秘密 提交于 2019-12-06 08:29:15
问题 I have a question which is an extension of the following question raised on this site. Is there a more elegant way to merge observables when return type is unimportant? I have an IObservable<Unit> (lets say X ), a reactive collection ( Y ) and a property ( Z ). Return type is not important. I just want to subscribe when any of these change. I know how to observe all 3 and Subscribe using Observable.Merge as below. Observable.Merge(X, Y.Changed, ObservableForProperty(Z).Select(_ => Unit

How to use ReactiveList so UI is updated when new items are added

北城余情 提交于 2019-12-06 07:38:11
I'm creating a Xamarin.Forms application with a list. The itemSource is a reactiveList. Adding new items to the list however does not update the UI. What is the correct way of doing this? List Definition _listView = new ListView(); var cell = new DataTemplate(typeof(TextCell)); cell.SetBinding(TextCell.TextProperty, "name"); cell.SetBinding(TextCell.DetailProperty, "location"); _listView.ItemTemplate = cell; Binding this.OneWayBind(ViewModel, x => x.monkeys, x => x._listView.ItemsSource); this.OneWayBind(ViewModel, x => x.save, x => x._button.Command); //save adds new items View Model public

Recommended way to test Scheduler/Throttle

时光总嘲笑我的痴心妄想 提交于 2019-12-06 07:28:19
I'm in the process of rewriting one little WPF-App I wrote to make use of ReactiveUI, to get a feeling about the library. I really like it so far! Now I've stumbled upon the Throttle method and want to use it when applying a filter to a collection. This is my ViewModel: namespace ReactiveUIThrottle { public class MainViewModel : ReactiveObject { private string _filter; public string Filter { get => _filter; set => this.RaiseAndSetIfChanged(ref _filter, value); } private readonly ReactiveList<Person> _persons = new ReactiveList<Person>(); private readonly ObservableAsPropertyHelper

How can I bind a command to a local event?

主宰稳场 提交于 2019-12-06 06:42:36
问题 I have a form that should capture KeyDown/KeyUp events. This code fails with NRE, because it looks for KeyDown control on my current view: this.BindCommand(ViewModel, vm => vm.KeyDown, "KeyDown"); What I've done is created wrapper class that has form as a property, so I can use this overload: this.BindCommand(ViewModel, vm => vm.KeyDown, v => v.Form, "KeyDown"); While it works, it seems like a hack to me. Is there a proper way to bind to local events? 回答1: That's the right way to do it if you

UICollectionView - too many update animations on one view

南楼画角 提交于 2019-12-05 14:18:25
Update: Solved! See my answer below for the solution. My app displays a number of images in a UICollectionView. And I'm currently experiencing a problem with insertItemsAtIndexPaths when new items are getting inserted too fast for the collection view to handle. Below is the exception: NSInternalInconsistencyException Reason: too many update animations on one view - limit is 31 in flight at a time Turns out this was caused by my model buffering up to 20 new images and pushing them to the datasource at once but not inside a collection view batch update block. The absence of the batch update is

How do I make a direct call to ReactiveCommand.Execute() in ReactiveUI 7 correct?

▼魔方 西西 提交于 2019-12-05 04:43:30
I'm trying to convert my project from ReactiveUI 6.5 to version 7. In the old version I called // var command = ReactiveCommand.Create...; // ... if(command.CanExecute(null)) command.Execute(null); in order to execute a command from my code behind. Now the CanExecute method is no longer available and replaced with a property of IObservable<bool> . Is the CanExecute Observable automatically called if I just make a call to Execute().Subscribe() or must I call it explicitly? For now I replaced the above code with command.Execute().Subscribe(); I found three different solutions to call my command

ReactiveList and WhenAny

左心房为你撑大大i 提交于 2019-12-05 01:14:48
问题 I have a number of check lists held in ReactiveLists that have ChangeTrackingEnabled = true . I want to only enable my OkCommand when there is at least one item checked in each list. In addition there are various other properties that I want to ensure are filled in with a valid byte value. I've tried doing the following but it doesn't work: this.OkCommand = new ReactiveCommand(this.WhenAny( x => x.Property1, x => x.Property1, x => x.Property1, x => x.List1, x => x.List2, x => x.List3, (p1, p2