我正试图找到一种方法来在命令的生命周期内更改ReactiveUI ReactiveCommand的谓词:
public class Form1ViewModel
{
public Form1ViewModel()
{
TestAction = () => Observable.Start(() => { MessageBox.Show("Initial step"); });
TestCommand = ReactiveCommand.CreateFromObservable(TestAction);
TestCommand.ThrownExceptions.Subscribe(ex => MessageBox.Show(string.Format("Something went wrong while executing test command: {0}", ex)));
TestAction = () => Observable.Start(() => { MessageBox.Show("Another step"); });
}
public ReactiveCommand TestCommand { get; set; }
public Func<IObservable<Unit>> TestAction { get; set; }
}
从绑定到此viewmodel的视图执行命令时,它始终显示“Initial step”消息而不是“Another step”。 任何想法都将不胜感激。
答案 0 :(得分:0)
您将TestAction的当前值传递给CreateFromObservable,然后更改了TestAction的值。那永远不会奏效。
你可以试试。
at SimpleInjector.Scope.GetScopelessInstance[TImplementation](ScopedRegistration`1 registration)
at SimpleInjector.Scope.GetInstance[TImplementation](ScopedRegistration`1 registration, Scope scope)
at SimpleInjector.Advanced.Internal.LazyScopedRegistration`1.GetInstance(Scope scope)
at lambda_method(Closure )
at SimpleInjector.InstanceProducer.GetInstance()
at SimpleInjector.Container.GetInstance(Type serviceType)
at Service.Core.ResolvingActivator.CreateInstance(Type type) in Service.Core\ResolvingActivator.cs:line 43
at Service.Core.ResolvingActivator.CreateInstance(String typeName) in Service.Core\ResolvingActivator.cs:line 35
at Service.Core.ResolvingActivator.CreateInstance[TService](String typeName) in Service.Core\ResolvingActivator.cs:line 69