Some Possibilities:
Hard-Coded References
The following approach would solve the problem. However, as it introduces hard-coded dependencies, using it is out of the question.
// in the master view model
var detailViewModel = new DetailViewModel(new AccountService(), new TransactionService());
Resolution via IoC Framework
Another option would be for the parent view model to hold a reference to an IoC framework. This approach introduces a master view model dependency on the IoC framewok.
// in the master view model
var detailViewModel = new DetailViewModel(resolver.GetNew<IAccountService>(), resolver.GetNew<IAccountService>());
Factory Func<>s
class MasterViewModel {
public MasterViewModel(Func<Service.IAccountService> accountServiceFactory, Func<Service.ITransactionService> transactionServiceFactory) {
this.accountServiceFactory = accountServiceFactory;
this.transactionServiceFactory = transactionServiceFactory;
// instances for MasterViewModel's internal use
this.accountService = this.accountServiceFactory();
this.transactionService = this.transactionServiceFactory():
}
public SelectedItem {
set {
selectedItem = value;
DetailToEdit = new DetailViewModel(selectedItem.Id, accountServiceFactory(), transactionServiceFactory());
}
// ....