Am I registering the view name so I can remove it correctly? Prism Unity wpf

Topics: Prism v4 - WPF 4
May 28, 2015 at 1:46 AM
Edited May 28, 2015 at 12:02 PM
Hi I'm registering my Views like this, but can't seem to get the name right to remove them. I get the views in my var vs, but It always errors when I try to remove it.

Error Message
{"The region does not contain the specified view.\r\nParameter name: view"}


Edit
fixed with the below code.
    private void CloseTab()
    {
       // var vs = _regionManager.Regions[RegionNames.ContentRegion].Views.ToList();
       //if (vs != null)
       // {
       //    _regionManager.Regions[RegionNames.ContentRegion].Remove(view:"CTUserView");
       // }
        List<object> views = new List<object>();
        List<object> removeViews = new List<object>();

        if (_regionManager.Regions[RegionNames.ContentRegion] != null)
        {
            foreach (object view in _regionManager.Regions[RegionNames.ContentRegion].ActiveViews)
            {
                views.Add(view);
            }
            for (int i = 0; i < views.Count; i++)
            {
                if (views[i].GetType().Name == "CTUserView" ||
                    views[i].GetType().Name == "AACustomersView" ||
                    views[i].GetType().Name == "ViewBView" ||
                    views[i].GetType().Name == "ViewAView")
                    removeViews.Add(views[i]);
            }

            if (removeViews.Count > 0)
                for (int i = 0; i < removeViews.Count; i++)
                {
                    _regionManager.Regions[RegionNames.ContentRegion].Remove(removeViews[i]);
                }
        }

   }
Marked as answer by ArodNom on 5/28/2015 at 4:00 AM