0

I'm attempting use a base class viewmodel from which all other viewmodels inherit to facilitate sharing between viewmodels. In the base class I use IoC, passing in an IDataService to the constructor.

//IoC
private readonly IDataService _dataService;

public BaseViewModel(IDataService localDataService)
{
    _dataService = localDataService;
}

Trouble is when creating a child view model that inherits, the base viewmodel constructor now expects an IDataService. I've seen this post: SQLite Connection Injection but I want to be clear that the proper course is to send the IDataService into the base class from all of my child viewmodels, of which there are about 5. Lacking real IoC understanding I'm concerned this might screw up the dataservice singleton.

Thanks Mark

Community
  • 1
  • 1
MarkAArnold
  • 127
  • 6
  • This is standard c# - see http://stackoverflow.com/questions/7230544/c-sharp-error-parent-does-not-contain-a-constructor-that-takes-0-arguments – Stuart Sep 08 '13 at 19:47
  • Perhaps you didn't see the last sentence of my post, regarding IoC. What I'm really asking is do I still have a singleton dataservice if I'm passing in IDataService from each child viewmodel. – MarkAArnold Sep 08 '13 at 20:38
  • IOC is still just c# too. It has to obey the normal c# constructor rules. If it helps, there's a full intro to mvx IOC on https://github.com/slodge/MvvmCross/wiki/Service-Location-and-Inversion-of-Control – Stuart Sep 09 '13 at 06:06

0 Answers0