Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:26:57+00:00 2026-05-30T00:26:57+00:00

I have a view let’s call it ‘NestedView’, which defines nested region, due to

  • 0

I have a view let’s call it ‘NestedView’, which defines nested region, due to lack of nested region support in XAML I create a view in UserControl constructor like this:

RegionManager.SetRegionName(RegionControl, "MyRegionName");
RegionManager.SetRegionManager(RegionControl, _globalRegionManager);

‘NestedView’ is shown (added) to some region let’s call it ‘MainRegion’, at some time I need to close this view (remove it from ‘MainRegion’). But If I simply remove ‘NestedView’ from ‘MainRegion’, the region it has registered ‘MyRegionName’ will remain registered, and the next time I will try to open ‘NestedView’ it will throw exception that region ‘MeregionName’ already registered.

So I need to make sure that when I close view that contain regions, they are unregistered, and all views they contain are disposed. What is the best way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:26:58+00:00Added an answer on May 30, 2026 at 12:26 am

    I came up with this method in NavigationService:

    public interface IRegionContainer
    {
        IEnumerable<String> RegionNames { get; }
    }
    
        public void RequestClose(string regionName, string viewContract)
        {
            ContainerRegistration registration = _unityContainer.Registrations.SingleOrDefault(t => t.Name == viewContract);
            if (registration == null) throw new Exception("ViewContract is not registered");
            IEnumerable<object> candidateViews = _regionManager.Regions[regionName].Views.Where(t => t.GetType() == registration.MappedToType);
            foreach (object viewInstance in candidateViews)
            {
                var regionContainer = viewInstance as IRegionContainer;
                if (regionContainer != null) //View defines regions?
                {
                    foreach (string rName in regionContainer.RegionNames)
                    {
                        var success = _regionManager.Regions.Remove(rName);
                        if (success == false) throw new Exception("Can't remove region: " + rName);
                    }
                }
                _regionManager.Regions[regionName].Remove(viewInstance);
            }
        }
    

    Also, PRISM 4.1 is out, and they claim to fix this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view which has an Int column which is nullable (let's call
I have created a custom View (let's call it MyView ) which basically just
I have a table view controller which doesn't let me manually scroll to the
Let's say you have a view called View Story which is just a web
I have two view controllers let's call them A and B (1) in A
Let’s say I have a view controller, or a window controller, which is (as
I have a view controller, let's call it HomeViewController , that pops up an
Here is a an interesting problem. I have a view controller, let's call it
So let's say I have a view that access a date: <%= Html.TextBoxFor(model =>
Let's say I have a split view, and I want to fill half of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.