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>
Hello Cubean,
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.
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); } }