Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

unity, newing up a class inside a viewmodel

$
0
0

Hi,

I've always been told that you don't inject unity into a viewmodel. Just what objects you need in a constructor etc.So lets say im in a private method.

Now I need to new up an object

var someclass = new classWithInterface();

Now my viewmodel is dependent on classWithinterface.

One way to get around this is to pass unity into the constructor and then use unity to resolve my ClassWithinterface object.

Is there any other means to achieve this? Was I wrong in assuming passing unity into the viewmodel is bad practise etc?

Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>