if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)

Dec 14, 2008 at 8:09 AM
Hello,

How to show a view more than one time in same region at the same time.?

Let's say I have a view called "PersonalDetails" and I'm using tab region. If the user open that view, I want to show that view in one tab. If the user open that view again then I want to show that view in different tab without closing the tab which is already opened.  I think that scoped region doesn't fix for that scenario.

Technically, I would like to remove this line from InnerAdd(object view, string viewName, IRegionManager scopedRegionManager) method of Region.cs.

if (ItemMetadataCollection.FirstOrDefault(x => x.Item == view) != null)
                throw new InvalidOperationException(Resources.RegionViewExistsException);

What will be the problem if I remove that line?
Dec 23, 2008 at 11:04 AM

Hi

 

Is there any special reason you want to add the same view instance several times in a region?

The normal behavior when you try to show a view that was previously added to a region should be activating it / giving focus to it. Check the following sample code:

IRegion tabRegion = this.regionManager.Regions["TabRegion"];

 

// _view2 is the instance of your PersonalDetails view that you want to show.

if (!tabRegion.Views.Contains(_view2))

{

mainRegion.Add(_view2);

}

 

mainRegion.Activate(_view2);

For a further sample you can check how the EmployeesDetailsView is showed in the UI Composition Quickstart.

 

If what you want is to create different tabs for each of your PersonalDetails views you should consider creating a different instance of it every time. I think that removing those lines in the InnerAdd method is not a good idea because could produce side effects in the normal behavior of your tabs.

 

Please let me know if this helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti

Dec 24, 2008 at 2:38 AM

Thanks. 

I have solved the problem by using the scoped region. I'm not sure what problem I'm going to face after switching from default region to scoped region. 

I'm currently facing some problems in switching views.. Could you please answer me this question http://www.codeplex.com/CompositeWPF/Thread/View.aspx?ThreadId=42843 ??  Thanks.