0
votes

This is my first post on StackOverflow so forgive me if I am not completely clear.

My WPF project uses PRISM 5.0 and Unity as the container. This is my first project using PRISM and Unity.

In my application, I am loading a View into my MainWindow correctly. This view displays a friendly version of information about an item. I have an edit button on this screen and I would like it to call up a modal window with the appropriate controls for editing this item. So far, I have chosen the InteractionRequestTrigger -> PopUpWindowAction approach as it was the most straight-forward seeming approach to achieve the result. I am not married to this approach.

However, I noticed I am not able to get dependency injection to work for the ViewModel constructor for the View I am trying to use in the modal. This is probably because I have not registered the View with a Region or done any of the associated leg work and the PopUpWindowAction is just plopping my user control onto a plain form if I had to guess.

My question is, can I achieve a modal dialog passing a custom View and ViewModel and have it behave as the parent View and ViewModel calling it? That is, supporting Dependency Injection and the like. After doing the edit logic, I'd like to ideally re-use the View and ViewModel for my add item functionality, but I am thinking I will be registering that View with the "Main Region" of my Shell and as such, would like to use dependency injection there as well.

Hopefully this is clear. I didn't think a code example would really help much here, but if so, let me know and I can put together a simple example illustrating the above.

1

1 Answers

0
votes

I would not provide tight-coupling between my main view-model and the view-model for my modal dialog.

Instead, I would consider using the EventAggregator that Prism provides to publish notifications that my main view-model can subscribe to and react accordingly.