How to get Region Hosting Control Type?

Topics: Prism v4 - WPF 4
Sep 8, 2011 at 5:58 AM

 <ContentControl x:Name="LoginStateRegion" 
                                                     Grid.Row="1"
                                                     Margin="0,5,0,5"
                                                      cal:RegionManager.RegionName="LoginStateRegion" 
                                                      HorizontalAlignment="Right" 
                                                      VerticalAlignment="Top"/>

How can I get the the hosting control Type(there is contentencontrol) In viewModel?

Developer
Sep 8, 2011 at 3:12 PM

Hi,

You could create a custom region behavior that implements IHostAwareRegionBehavior, which provides a HostControl property to get or set the hosting control the region is attached to, and then obtain the type from the control retrieved through that property.

You will find more information about this in the following links of the Prism documentation:

Note: there is a mistake in the interface name in the documentation, IHostControlAwareBehavior should be IHostAwareRegionBehavior

 I hope you find this useful.

Agustin Adami
http://blogs.southworks.net/aadami

Sep 8, 2011 at 3:52 PM

Thank you!