Is Dependency Injection possible with a WPF application?

前端 未结 8 1003
忘了有多久
忘了有多久 2021-01-30 21:05

I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern. I\'m looking at Aut

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 21:40

    I wrote an very light framework where a ViewModel is resolved at runtime by using a IoC (Unity) as a markup extension.

    The framework allows for writing XAML without a code behind but still lets you have routed commands, data binding, and event handlers.

    In any case, I don't think you need the loose XAML in your case, but if you look at the code (http://xtrememvvm.codeplex.com), it might turn out that you can use some of the code to solve your own issues with injecting View Models and Services.

提交回复
热议问题