how to get the container handle in a view

Topics: Prism v4 - WPF 4
Mar 2, 2012 at 2:31 PM

let's say the view is contained in a DevExpress DockPanel

I'd like to change some properties of he dockpanel, is there a way to get the container handle ?

Mar 2, 2012 at 3:49 PM


Based on my understanding, usually a view should never know its container element. Like this, the view can be abstracted from the logic and implementation details of the rest of the application's UI, making it more maintainable, testable and less error prone.

However, if you need to communicate between a view and its container, you could take advantage of the different approaches proposed to communicate between loosely coupled components. For example, the parent view could subscribe to an event through the event aggregator and the child view could inform the parent one that a change must be performed by publishing an event.

You can find more information about this in the following chapter of the Prism documentation:

Note that, if you want to obtain the container of the view, you could retrieve it through the Parent property of the view. However, as far as I know, this is not a recommended practice.

I hope you find this useful,

Damian Cherubini