0

I was thinking something like.

<Window.DataContext>
    <ObjectDataProvider ObjectType="vm:MainViewModel">
        <ObjectDataProvider.ConstructorParameters>
            <interfaces:INavigationDataProvider/>
        </ObjectDataProvider.ConstructorParameters>
    </ObjectDataProvider>
</Window.DataContext>

Can it be done this way somehow, or i need to set DataContext in code behinde in constructor (that im trying to avoid completly). Thanks in advance :)

ivica.moke
  • 1,054
  • 2
  • 10
  • 19
  • `` doesn't work because it is basically attempt to create an instance of interface (`new INavigationDataProvider()`) which is not allowed. Specify concrete implementation for parameter, e.g. : ```` – ASh Mar 13 '17 at 13:52
  • Thanks for fast answer :) So maybe if i put it in some unityContainer and provide that class implementing that Interface, then could be done? – ivica.moke Mar 13 '17 at 14:00
  • I'm sure you can use IoC container of your choice in wpf app. these posts can give some ideas: http://stackoverflow.com/questions/25366291/how-to-handle-dependency-injection-in-a-wpf-mvvm-application; http://stackoverflow.com/questions/1802419/how-can-i-combine-mvvm-and-dependency-injection-in-a-wpf-app – ASh Mar 13 '17 at 14:10
  • Thanks, i'll check it up. – ivica.moke Mar 13 '17 at 14:59

0 Answers0