Recently I use XamDockManager and TabGroupPane with Prism 4.1 for silverlight 5 in v12.1,
I add RegionManager.RegionName in TabGroupPane and need to add a TabGroupPaneRegionAdapter class.
But I only found the abandoned project http://ncal.codeplex.com/
Anyone has some good suggestion?
some old code in codeplex: https://compositewpfcontrib.svn.codeplex.com/svn/Trunk/src/Extensions.Infragistics/Composite.Wpf.Infragistics/CompositeWPFContrib.Composite.Wpf.Infragistics/XamDockManager/Regions/TabGroupPaneRegionAdapter.cs
Bootstrapperprotected override RegionAdapterMappings ConfigureRegionAdapterMappings() { RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings(); mappings.RegisterMapping(typeof(TabGroupPane),
new TabGroupPaneRegionAdapter(Container.Resolve<IRegionBehaviorFactory>())); return mappings; } XAML <igDock:XamDockManager Grid.Row="2" x:Name="dockManager" > <igDock:DocumentContentHost> <igDock:SplitPane VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <igDock:TabGroupPane Name="TabGroupPane1" prism:RegionManager.RegionName="{Binding TabRegion,Source={StaticResource RegionNames}}"
prism:RegionManager.RegionContext="{Binding CurrentView}"
VerticalAlignment="Top"/> </igDock:SplitPane> </igDock:DocumentContentHost> </igDock:XamDockManager>
Use this Prism region Adapter for the XamDockManager
http://brianlagunas.com/2012/09/12/xamdockmanagera-prism-regionadapter/
Hello Cubean,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.
I have been looking into your latest response and am glad to hear you have been able to resolve the first issue. Regarding 2) the difference in the ContentPane class are not due to the version, since the Silverlight XamDockManger is a different control than the WPF’s XamDockManager. In Silverlight there are PaneClosing and PaneClosed events exposed by the XamDockManger instance, however if you’d like to be able to register for such a notification directly through the ContentPane’s instance you can try out handling the PropertyChanged event like so:
private void ContentPane_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "OwnerPane" && (sender as ContentPane).OwnerPane == null)
//CLOSED ACTIONS here
}
Hope this helps. Looking forward to hearing from you.
OK. These days, I have realized my functions by reuse the abandoned code. I share it in attachment.
But it's not perfect, because still there are some problems in new code. If it's prossible, please assist me to resolve these.
1. FindDockManager function, how to find the host DockManager in TabGroupPane ?
I cannot find the FindDockManager() in new TabGroupPane class and XamDockManager.GetDockManager(child), so I cannot use the AttachBehaviors to realize view activation in exist tabs.
protected override void AttachBehaviors(IRegion region, TabGroupPane regionTarget) { base.AttachBehaviors(region, regionTarget);
//XamDockManagerActiveAwareBehavior syncBehavior = new XamDockManagerActiveAwareBehavior(regionTarget.FindDockManager(), region); //syncBehavior.Attach(); }
2. I cannot find Closed event of ContentPane in v12.1, so ...
//When contentPane is closed remove the associated region //newContentPane.Closed += delegate(object contentPaneSender, PaneClosedEventArgs args) //{ // OnContentPaneClosed((ContentPane)contentPaneSender, args, region); //};
But I resolved the first problem by first to active exist pane in view code behind then if it not exist, create new region.
public class MainBootstrapper : UnityBootstrapper {
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() { RegionAdapterMappings regionAdapterMappings = base.ConfigureRegionAdapterMappings(); IRegionBehaviorFactory regionBehaviorFactory = Container.TryResolve<IRegionBehaviorFactory>();
if (regionAdapterMappings != null && regionBehaviorFactory != null) { regionAdapterMappings.RegisterMapping(typeof(TabGroupPane), new TabGroupPaneRegionAdapter(regionBehaviorFactory)); }
return regionAdapterMappings; }
TabGroupPaneRegionAdapter class in attachment.
<ig:XamDockManager x:Name="mainDockManager" >
<ig:XamDockManager.Content> <ig:DocumentContentHost>
<ig:DocumentContentHost.Panes>
<ig:TabGroupPane Name="mainTabGroup" prism:RegionManager.RegionName="{Binding TabRegion,Source={StaticResource RegionNames}}" prism:RegionManager.RegionContext="{Binding CurrentView}" TabNavigation="Cycle" IsTabStop="True" Location="Right" > </ig:TabGroupPane> </ig:DocumentContentHost.Panes>
</ig:DocumentContentHost> </ig:XamDockManager.Content> </ig:XamDockManager>
public partial class MainFrame : UserControl { TabGroupPane _mainTab; TabGroupPane MainTab { get { return _mainTab ?? (_mainTab = this.mainDockManager.FindName("mainTabGroup") as TabGroupPane); } }
public MainFrame(MainFrameViewModel viewModel) { this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
InitializeComponent();
DataContext = viewModel;
viewModel.ActivePaneEvent += ViewModelActivePaneEvent; }
bool ViewModelActivePaneEvent(AzElement data) { Debug.Assert(MainTab != null, "MainTab != null"); var cp = MainTab.Panes.FirstOrDefault(p => (p.Content as UIElement).GetContentPaneMetadata().ClassName == data.ClassName); if (cp != null) { return cp.IsActivePane = true; }
return false; } }
public sealed class MainFrameViewModel : INotifyPropertyChanged {
private void SetEntityActiveData(AzElement data) { if (ActivePaneEvent != null) { if (!this.ActivePaneEvent(data)) { if (data != null) { if (_modulesName.Contains(data.AssemblyName)) { LoadView(); return; }
_moduleManager.LoadModuleCompleted += ChildFramePaneLoadModuleCompleted;
_moduleManager.LoadModule(data.AssemblyName); } } }
void LoadView() { this._eventAggregator.GetEvent<MenuSelectedEvent>().Publish(new MenuInfo() { AssemblyName = CurrentView.AssemblyName, ClassName = CurrentView.ClassName, ContentHeader = CurrentView.Name });
public class LogMgtModule : IModule { private readonly IRegionManager _regionManager; private readonly SubscriptionToken _subscriptionToken;
public LogMgtModule(IRegionManager regionManager, IEventAggregator eventAggregator) { _regionManager = regionManager;
var menuSelectedEvent = eventAggregator.GetEvent<MenuSelectedEvent>();
if (_subscriptionToken != null) { menuSelectedEvent.Unsubscribe(_subscriptionToken); }
_subscriptionToken = menuSelectedEvent.Subscribe(this.MenuSelected, ThreadOption.UIThread, true, menuInfo => menuInfo.AssemblyName == "LogMgtModule"); }
public void Initialize() { }
private void MenuSelected(MenuInfo info) { var newView = Assembly.GetExecutingAssembly().CreateInstance(info.ClassName) as UserControl; Debug.Assert(newView != null, "newView != null"); IContentPaneMetadata tabGroupPaneMetadata = new ContentPaneMetadata(); tabGroupPaneMetadata.Header = info.ContentHeader; tabGroupPaneMetadata.ClassName = info.ClassName;
newView.SetContentPaneMetadata(tabGroupPaneMetadata);
this._regionManager.RegisterViewWithRegion(RegionNames.TabRegion, () => newView); } }
I have been looking into your enquiry and actually the adapter you have seen in the link is for the WPF XamDockManager which is a different control than the SL’s XamDockManager, for which there hasn’t been any such implementation. Actually the WPF project was abandoned due to the lack of interest.
If you decide on making an adapter of your own and encounter any obstacles, we’d be glad to assist with anything we can. Also if you manage to create one, it would be useful for other community users, if you were to share it.
Looking forward to hearing from you.