This is a migrated thread and some comments may be shown as answers.

Unable to find PRISM regions defined inside RadExpander content

4 Answers 76 Views
Expander
This is a migrated thread and some comments may be shown as answers.
Syam
Top achievements
Rank 1
Syam asked on 22 Sep 2011, 02:31 PM
Hi,

I am placing a region "JobTabRegion"(using a ContentControlin the DataTemplate of  a RadTabControl in my Shell. This "JobTabRegion" is bind to view named "MainJobView" which in turn has a RadTabControl and regions are marked inside the RadTabItem.Content (using a ContentControlof each RadTabItem. One such region would be "JobRequestRegion" which is bind to a view named "JobRequestView". This "JobRequestView" has a RadExpander control and I am having a region marked (using a ContentControlinside the RadExpander.Content called "ExpanderRegion" . I am using two buttons to switch the contents of the RadExpander. To do so, in the ViewModel of  "JobRequestView", when i try to access the "ExpanderRegion" from the Region Manager instance, i get an error saying "The region manager does not contain the ExpanderRegion region." 

I have read in an article that the regions marked inside a DataTemplate will not be available in the RegionCollection of the Region Manager. But i didn't get any proper solution. I am using PRISM v 4 and Silverlight 4.

Any help would be appreciated. Thanks in advance.

Syam


4 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 27 Sep 2011, 02:37 PM
Hello Syam,

In order to implement your scenario you'll need to manually set the region manager so that you can access the ExpanderRegion:
RegionManager.SetRegionManager(contentControl,(this.DataContext as JobRequestViewModel).MyRegionManager);

I attached a sample project to get you started. Give it a try and let me know if it helps.

Best wishes,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Syam
Top achievements
Rank 1
answered on 28 Sep 2011, 05:12 AM
Hi Tina,

Thanks for you reply. I will try this out and let you know.
0
Syam
Top achievements
Rank 1
answered on 29 Sep 2011, 07:08 AM
Hi Tina,

Thanks for your solution. It worked and I was able to get the "ExpanderRegion" in the RegionManager's region collection. In your solution, you are binding two different views to the "ExpanderRegion" using the following condition:

if (param.ToString().Contains("1"))
this.MyRegionManager.Regions["ExpanderRegion"].Activate(this.MyRegionManager.Regions["ExpanderRegion"].Views.FirstOrDefault());
else
this.MyRegionManager.Regions["ExpanderRegion"].Activate(this.MyRegionManager.Regions["ExpanderRegion"].Views.LastOrDefault());

In my case i need to bind more than 2 Views into this region and also it might come from different Prism Modules. How would i do that ? 

Thanks in advance
Syam 

0
Tina Stancheva
Telerik team
answered on 30 Sep 2011, 04:15 PM
Hi Syam,

You can use the same approach even if the vies in the ExpanderRegion are added from different modules. I modified slightly the sample project so please have a look at it and let me know if it helps. Also, if I'm missing something from your scenario, let me know.

Kind regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Expander
Asked by
Syam
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Syam
Top achievements
Rank 1
Share this question
or