Unable to find PRISM regions defined inside RadExpander content

5 posts, 0 answers
  1. Syam
    Syam avatar
    13 posts
    Member since:
    Aug 2011

    Posted 22 Sep 2011 Link to this post

    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


  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 27 Sep 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Syam
    Syam avatar
    13 posts
    Member since:
    Aug 2011

    Posted 28 Sep 2011 Link to this post

    Hi Tina,

    Thanks for you reply. I will try this out and let you know.
  5. Syam
    Syam avatar
    13 posts
    Member since:
    Aug 2011

    Posted 29 Sep 2011 Link to this post

    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 

  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 Sep 2011 Link to this post

    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 >>

Back to Top
DevCraft banner