Winforms MVP with Castle Windsor - DI for subforms?

Posted by Paul Kirby on Stack Overflow See other posts from Stack Overflow or by Paul Kirby
Published on 2010-04-15T01:48:00Z Indexed on 2010/04/15 1:53 UTC
Read the original article Hit count: 577

I'm building a winforms app utilizing passive-view MVP and Castle Windsor as an IoC container. I'm still a little new to dependency injection and MVP, so I'm looking for some clarity...

I have a main form which contains a number of user controls, and also will bring up other dialogs (ex. Login, options, etc) as needed. My first question is...should I use constructor injection to get the presenters for these other views into the main view, or should I go back to a Service Locator-type pattern? (which I've been told is a big nono!) Or something else?

Second question...the user controls need to communicate back to the main form when they are "completed" (definition of that state varies based on the control). Is there a standard way of hooking these up? I was thinking perhaps just wiring up events between the main presenter and the child presenters, but I'm not sure if this is proper thinking.

I'd appreciate any help, it seems that the combination of MVP and IoC in winforms isn't exactly well-documented.

© Stack Overflow or respective owner

Related posts about c#

Related posts about mvp