Skip to content

Dependency Injection in WPF #9022

Answered by jamesnet214
DavidM29 asked this question in Q&A
Discussion options

You must be logged in to vote

In the WPF and .NET environment, there are several approaches to managing pages and view models through dependency injection. One of the most popular methods involves using a framework like Prism. With Prism, when a view is created, the associated view model is automatically generated, and necessary dependencies are injected through the constructor. This allows for efficient and flexible dependency management without explicitly declaring the view model within the XAML.

However, even without using a library like Prism, it is possible to use reflection to identify what instances are required by the constructor of a view model and inject these dependencies directly. This method enables you t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@DavidM29
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidM29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants