ViewModel WhenActivated is not called (resp. Compiler error CS0121 "Ambiguous call") #3504
-
Hi, I am evaluating ReactiveUI and created a vanilla app with only one ViewModel and View (net6.0-windows, ReactiveUI v18.4.26)
Problem1: The compiler complains about an ambiguous call in the ViewModel: Problem2: If I avoid the error by qualifying the args of the call, then none of the Methods is called. The problem occurs with the current VS2022 version (17.5.2) and with Rider as well Attached a zip of the solution |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @adaxer, Please update your viewmodel as follows, the way in which you initialised your property will return a new activator every time. public class MainViewModel : ReactiveObject, IActivatableViewModel
{
public MainViewModel()
{
Activator = new ViewModelActivator();
this.WhenActivated((CompositeDisposable d) =>
{
Console.WriteLine("WhenActivated");
});
this.WhenActivated((Action<IDisposable> a) =>
{
Console.WriteLine("WhenActivated");
});
}
public ViewModelActivator Activator { get; }
} I hope that this helps you. |
Beta Was this translation helpful? Give feedback.
Hi @adaxer,
Firstly you need to target windows 10.0.17763.0 + to use the latest ReactiveUI due to compatibility with other dependencies, please change to the following minimum version or above.
net6.0-windows10.0.17763.0
Please update your viewmodel as follows, the way in which you initialised your property will return a new activator every time.
Once you have done this you should be up and running.