This project has moved. For the latest updates, please go here.

TabRegion

Apr 7, 2011 at 1:50 PM

How to Deactivate Tab (Hide) and Activate Tab (Show) for your Quick Starts Example

Apr 8, 2011 at 4:24 PM

How to Write The Same in MEF

 /// <summary>    /// A Blend trigger action to remove a view from a tab control region.    /// </summary>    public class CloseTabbedViewAction : TriggerAction<FrameworkElement>    {        protected override void Invoke( object parameter )        {            RoutedEventArgs args = parameter as RoutedEventArgs;            if ( args == null ) return;
            // Find the parent tab item that contains the view to remove.            TabItem tabItem = FindVisualParent<TabItem>( args.OriginalSource as DependencyObject );
            // Find the parent tab control that represents the region.            TabControl tabControl = FindVisualParent<TabControl>( tabItem );
            if ( tabControl != null && tabItem != null )            {                // Get the view.                object view = tabItem.Content;
                // Get the region associated with the tab control.                IRegion region = RegionManager.GetObservableRegion( tabControl ).Value;                if ( region != null )                {                    NavigationContext context = new NavigationContext( region.NavigationService, null );
                    // See if the view (or its view model) supports the INavigationAware interface.                    // If so, call the OnNavigatedFrom method.                    NotifyIfImplements<INavigationAware>( view, i => i.OnNavigatedFrom( context ) );
                    // See if the view (or its view model) supports the IConfirmNavigation interface.                    // If so, call the ConfirmNavigationRequest method. If not, just remove the view from the region.                     if ( !NotifyIfImplements<IConfirmNavigationRequest>( view,                        i => i.ConfirmNavigationRequest( context,                        canNavigate => { if ( canNavigate ) if ( region != null ) region.Remove( view ); } ) ) )                    {                        // Remove the view.                        region.Remove( view );                    }                }            }        }
        private T FindVisualParent<T>( DependencyObject node ) where T : DependencyObject        {            DependencyObject parent = VisualTreeHelper.GetParent( node );            if ( parent == null || parent is T ) return (T)parent;
            // Recurse up the visual tree.            return FindVisualParent<T>( parent );        }
        private T Implementor<T>( object content ) where T : class        {            T impl = content as T;            if ( impl == null )            {                FrameworkElement element = content as FrameworkElement;                if ( element != null ) impl = element.DataContext as T;            }            return impl;        }
        private bool NotifyIfImplements<T>( object content, Action<T> action ) where T : class        {            bool notified = false;
            // Get the implementor of the specified interface - either the view or the view model.            T target = Implementor<T>( content );            if ( target != null )            {                action( target );                notified = true;            }            return notified;        }    }

Apr 8, 2011 at 4:24 PM

For Reference http://blogs.msdn.com/b/dphill/archive/2011/01/23/closable-tabbed-views-in-prism.aspx

How can i do this in MEF using Jounce.. please post the solution.