public static void RegisterMasterTab <T>(this IRegionManager regionManager, string subTabRegionName, string contentRegionName, string tabRegion, IWhitelistedServiceLocator whitelistedServiceLocator) where T : class, ITabViewModel, IWhitelisted { regionManager.RegisterViewWithRegion(tabRegion, () => { ITabViewModel viewModel = whitelistedServiceLocator.GetInstance <T>(); var tab = new TabItem(); var masterIconTabHeader = new MasterIconTabHeader(subTabRegionName); var contentContainer = new Grid(); var tabContent = new ContentControl(); tabContent.Padding = ContentPadding; tabContent.IsTabStop = false; tab.Header = masterIconTabHeader; tabContent.SetValue(RegionManager.RegionNameProperty, contentRegionName); tabContent.DataContext = viewModel; masterIconTabHeader.DataContext = viewModel; contentContainer.Children.Add(tabContent); AddGpoBehavior(tab, contentContainer, viewModel); tab.Content = contentContainer; return(tab); }); }
public static void RegisterMasterTab <T>(this IRegionManager regionManager, string subTabRegionName, string contentRegionName, string tabRegion, IWhitelistedServiceLocator whitelistedServiceLocator, IEventAggregator eventAggregator) where T : class, ITabViewModel, IWhitelisted { regionManager.RegisterViewWithRegion(tabRegion, () => { ITabViewModel viewModel = whitelistedServiceLocator.GetInstance <T>(); var tab = new TabItem(); var masterIconTabHeader = new MasterIconTabHeader(subTabRegionName); var contentContainer = new Grid(); var tabContent = new ContentControl { IsTabStop = false }; tabContent.SetResourceReference(FrameworkElement.StyleProperty, "TabUserControl"); tab.Header = masterIconTabHeader; tabContent.SetValue(RegionManager.RegionNameProperty, contentRegionName); tabContent.DataContext = viewModel; tabContent.Loaded += (sender, args) => { var helpTopic = HelpTopic.ProfileSettings; var dependencyObjects = (args.OriginalSource as ContentControl).GetChildObjects(); if (dependencyObjects.First() is DependencyObject view) { helpTopic = (HelpTopic)view.GetValue(HelpProvider.HelpTopicProperty); } eventAggregator.GetEvent <SetProfileTabHelpTopicEvent>().Publish(helpTopic); }; masterIconTabHeader.DataContext = viewModel; contentContainer.Background = new SolidColorBrush(Colors.White); contentContainer.Children.Add(tabContent); AddGpoBehavior(tab, contentContainer, viewModel); tab.Content = contentContainer; TransposerHelper.Register(masterIconTabHeader, viewModel); TransposerHelper.Register(tabContent, viewModel); return(tab); }); }