Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Prism/MEF: how to create nested components with regions

$
0
0

Hello

I'm having the following problem.

I want to implement ribbon-based app with ribbon tabs as separate MEF component which can also contain MEF components - ribbon groups.

In my shell.xaml I have following code:

<ribbon:Ribbon x:Name="Ribbon" cal:RegionManager.RegionName="AplicationRibbonControl">
            ........</ribbon:Ribbon>

For my Tab components I have following code in XAML:
<ribbon:RibbonTab x:Class="FI.VMRT.ObjectsTabUI"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:cal="http://www.codeplex.com/prism"             
             xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
             x:Name="ObjectsTab"
             Header="Objects"
             cal:RegionManager.RegionName="ObjectsTabControl"></ribbon:RibbonTab>
And for my ribbon tab group component:
<ribbon:RibbonGroup x:Name="PlacementGroup" 
                    Header="Placement" 
                    x:Class="FI.VMRT.PlacementGroupUI"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
             xmlns:alp="clr-namespace:FI.Family.AkerLogoPack;assembly=AkerLogoPack"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"><Grid>
.... controls here .......</Grid></ribbon:RibbonGroup>
And while loading the application in my ribbon tab modude when I'm calling this:
_regionViewRegistry.RegisterViewWithRegion("AplicationRibbonControl", typeof(ObjectsTabUI));

I'm getting the following error:
An exception has occurred while trying to add a view to region 'AplicationRibbonControl'. 
    - The most likely causing exception was was: 'Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ObjectsTabUI, key "" ---> Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type ObjectsTabUI, key ""
   at Microsoft.Practices.Prism.MefExtensions.MefServiceLocatorAdapter.DoGetInstance(Type serviceType, String key)
   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   --- End of inner exception stack trace ---
   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType)
   at Microsoft.Practices.Prism.Regions.RegionViewRegistry.CreateInstance(Type type)
   at Microsoft.Practices.Prism.Regions.RegionViewRegistry.<>c__DisplayClass1.<RegisterViewWithRegion>b__0()
   at Microsoft.Practices.Prism.Regions.Behaviors.AutoPopulateRegionBehavior.OnViewRegistered(Object sender, ViewRegisteredEventArgs e)'.
    But also check the InnerExceptions for more detail or call .GetRootException(). 

If I'm removing my ribbon tab group component, evertything works fine - I have an empty tab inserted into ribbon on my Shell window.
Can someone please give me a hint,  why this error occurs when I'm trying to add nested component?
Thank you!


Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>