I am facing a small problem with Regions when using Microsoft Prism in WPF. One of the read only views is opened by default but it allows to open new views in same region. As part of testing it was discovered that all new views always disappearing after using "New Horizontal/Vertical Tab Group" option for read-only view and then closing all other opened views next to read-only.
Please help me for correcting this behavior as I can't find samples how to use single region name after moving one of the views to other new Tab group command.
In the debugging mode I see that both views still registered with same region but opening a new view never works after closing all other views.
Possible option would be to disable this context menu options for read-only view only. But I was unable to find how to do this. All views having tabs in the header for manipulating order, hiding, undocking or closing view.
I have done an initial investigation with my colleagues regarding this forum thread, and I believe we may need a bit more information from you in order to really be able to continue with this issue.
I am not particularly familiar with this "New Horizontal/Vertical Tab Group" option that you are referring to in this case, but it sounds like you are likely using the TabGroupPaneRegionAdapter in Prism with the XamDockManager, as is described here: http://brianlagunas.com/xamdockmanageran-updated-prism-region-adapter/. If this is not the case, please let me know.
Outside of the above mentioned impression that I am under, I cannot really say exactly what might be hiding the panes in your XamDockManager, although I am personally not extremely familiar with Prism libraries. Would it be possible for you to please attach an isolated sample project that demonstrates this behavior that you are seeing so that I may be able to debug it and shed some light on what may be happening in this case?
Please let me know if you have any other questions or concerns on this matter.
Yes, this implementation is used in our application. It seems that there were two more updated done since first version which we have. I will do an update of version and will check if problem still persist.
Also I would need to clarify that there are two options to move to new region: "New Horizontal Tab Group" and "New Vertical Tab Group" as in screenshot provided below.
After merging all changes and the problem still persist. Also tried to create a new separate test application but at the moment it is functioning correctly. So not able to reproduce the cause of error.
With new changes now I see that single region is disappearing from region list on navigation. I managed to find out how the region is getting removed and it looks very strange. This is a stack trace of removal of region:
XXXXXXXXXXXXXX.Service.dll!XXXXXXXXXXXXXX.Service.MainRegionController..ctor.AnonymousMethod__3_0(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Line 63 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.RegionManager.RegionCollection.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) Line 375 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.RegionManager.RegionCollection.Remove(string regionName) Line 352 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.Behaviors.RegionManagerRegistrationBehavior.TryRegisterRegion() Line 120 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.Behaviors.RegionManagerRegistrationBehavior.OnUpdatingRegions(object sender, System.EventArgs e) Line 142 C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Delegate.DynamicInvokeImpl(object args) Unknown
mscorlib.dll!System.Delegate.DynamicInvoke(object args) Unknown
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Events.WeakDelegatesManager.Raise(object args) Line 48 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.RegionManager.UpdateRegions() Line 225 C#
Microsoft.Practices.Prism.dll!Microsoft.Practices.Prism.Regions.RegionManager.RegionCollection.this[string].get(string regionName) Line 304 C#
XXXXXXXXXXXXXX.Core.dll!XXXXXXXXXXXXXX.Core.Prism.NavigationExtensions.RequestNavigate(Microsoft.Practices.Prism.Regions.IRegionManager regionManager, string regionName, System.Uri target, System.Action<Microsoft.Practices.Prism.Regions.NavigationResult> navigationCallback, System.Collections.Generic.IDictionary<string, object> navigationParameters) Line 69 C#
XXXXXXXXXXXXXX.Core.dll!XXXXXXXXXXXXXX.Core.Prism.NavigationExtensions.RequestNavigate(Microsoft.Practices.Prism.Regions.IRegionManager regionManager, string regionName, string target, System.Collections.Generic.IDictionary<string, object> navigationParameters) Line 42 C#
XXXXXXXXXXXXXX.Core.dll!XXXXXXXXXXXXXX.Core.Prism.NavigationExtensions.RequestNavigate(Microsoft.Practices.Prism.Regions.IRegionManager regionManager, string regionName, string target, string parameterName, object parameterValue) Line 31 C#
XXXXXXXXXXXXXX.Service.dll!XXXXXXXXXXXXXX.Service.MainRegionController.ShowCellSummary(XXXXXXXXXXXXXX.Core.FactoryModel.CellInstances.CellXXXXXViewModell cellInstance) Line 117 C#
> XXXXXXXXXXXXXX.Navigation.dll!XXXXXXXXXXXXXX.Navigation.Operations.NavigationTreeViewModelBase.HandleOpenItem(XXXXXXXXXXXXXX.Core.FactoryModel.CellXXXXXViewModel host) Line 559 C#
Removal of region is caused by navigation request line : var region = regionManager.Regions[regionName];
public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri target,
Action<NavigationResult> navigationCallback, IDictionary<string, object> navigationParameters)
if (regionManager == null) throw new ArgumentNullException(nameof(regionManager));
var region = regionManager.Regions[regionName];
region.RequestNavigate(target, navigationCallback, navigationParameters);
This line causes update after which region is getting removed despite fact that moved view still is opened and it still depends to the Main region.
My steps to get this error:
The differences with sample application: the view is split into multiple regions and selection of Tree view node in different region causes to open the view in Main region.
I've attached sample project based on GitHub link above with partially transferred our code but it works correctly at the moment.
Thank you for your updates on this matter and for the clarification that you are using the TabGroupPaneRegionAdapter.
Unfortunately, the sample project that you have provided isn't really much help in this case, as it does not appear to reproduce the issues that you are seeing, and it does not appear that the RequestNavigate code that you have provided exists anywhere within this sample, either.
I had tried to follow the steps you provided as well, although there is no "second view" next to the main "Start Page" view, and there also is no "New Horizontal/Vertical Tab Group" options in the context menu for the tab. It also appears from the stack-trace that you have attached that nothing Infragistics-related is involved - it is near-entirely a Prism-based stack.
As such, I will again request the attachment of a sample project that reproduces the behavior that you are seeing so that I may look into this further and move forward with this issue that you are seeing.