Prismv4FrameRegionNavigation Issue

Topics: Prism v4 - Silverlight 4
May 11, 2011 at 2:22 PM
Edited May 11, 2011 at 5:53 PM

Hi,

I hope this post finds you all well.

I am using Silverlight 4 + PRISM v4 + Unity

I am trying to use your Prismv4FrameRegionNavigation in my Silverlight 4 project but I am having some issues.

I have only one module in my app - CodeGeneratorModule - and I created it as a Silverlight Application project. I am not sure if this is causing the problem since it is not packaged in the main Silverlight application XAP.

When I run the application I get no errors but nothing is displayed in the shell. Well I get System.Object even though I am using the right way to register the types in the containder as per  you article.

In his article Karl said  " Intercept the navigation request, verify the assembly is loaded then proceed with the navigation request. If the assembly is not loaded or is in the process of loading, you can wait until the assembly loads, and then proceed with the request. "

Please could you provide some sample code of how to do that since I am not sure how and where to write this code. Would I intercept the navigation in the OnNavigatedTo(NavigationContext navigationContext) of the view model?

Cheers

Please see some code below:

ViewModel

public class CodeGenViewViewModel : ViewModelBase, INavigationAware, IRegionMemberLifetime, IPageTitle
    {
        readonly IRegionManager _regionManager;
        public CodeGenViewViewModel(IRegionManager regionManager)
        {
           _regionManager = regionManager;
        }
       
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            var test = 1;
        }

        String IPageTitle.PageTitle
        {

            get { return "Code Generator"; }
        }

        void CloseExecute()
        {
            _keepAlive = true;
            //_regionManager.RequestNavigate(RegionNames.MainContentRegion, "regionNAme");
        }

        Boolean _keepAlive = true;
        Boolean IRegionMemberLifetime.KeepAlive
        {
            get { return _keepAlive; }
        }

    }

This is how I register my ViewModel and View

public ModuleInit(IUnityContainer container)
{
            container
                .RegisterType<CodeGenViewViewModel>()
                .RegisterType<Object, CodeGenView>(typeof(CodeGenView).FullName);
}


In my BootStrapper I have tried both approaches below to create/configure the Catalog. However I would prefer using the CreateFromXaml since I do
not want to have a reference to the module in my main Silverlight project.

protected override IModuleCatalog CreateModuleCatalog()
 {
        return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/CodeGenerator;component/ModuleCatalog.xaml", UriKind.Relative));

}

or

 protected override void ConfigureModuleCatalog()
        {
            var moduleInitModuleType = typeof(ModuleInit);
            this.ModuleCatalog.AddModule(
                new ModuleInfo
                {
                    ModuleName = moduleInitModuleType.Name,
                    ModuleType = moduleInitModuleType.AssemblyQualifiedName,
                    InitializationMode = InitializationMode.WhenAvailable,
                });
        }

 }

This is my Shell.xaml

<Border Style="{StaticResource ContentBorderStyle}" Grid.Row="1">
                <navigation:Frame
                x:Name="ContentFrame"
                Style="{StaticResource ContentFrameStyle}"
                Source="/CodeGeneratorModule/CodeGenView"
                Navigated="ContentFrame_Navigated"
                NavigationFailed="ContentFrame_NavigationFailed"
                prism:RegionManager.RegionName="MainContentRegion"
                >

                    <navigation:Frame.ContentLoader>
                        <prism_Regions:FrameContentLoader RegionName="MainContentRegion"/>
                    </navigation:Frame.ContentLoader>

                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>

                            <!--Used to view a page-->
                            <uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="CodeGenerator.{moduleName}.Views.{pageName}"/>


                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>
</Border>

May 11, 2011 at 5:52 PM

Hi,

I have a bit more of informtion and questions:

Karl's demo app you used NavigateUri="/Inventory/InventoryView"

However the app does not have any modules with Inventory name. The module name is ThePhoneCompany.Inventory. Could you please explain that to me?

This is what I have in my APP:

CodeGenerator
CodeGenerator.Web
CodeGeneratorModule
Prismv4FrameRegionNavigation

I do not have a dot after my module name like you do.    CodeGeneratorModule.

Do you think that my NavigateUri and UriMapping are set wrongly? Pleae note that I have corrected a typo in my previous post.

Source="/CodeGeneratorModule/CodeGenView"
<uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="CodeGenerator.{moduleName}.Views.{pageName}"/>

I really would like to get it to work. Also could you please clarify if the library will work with Silverlight application modules instead of Silverlight class libraries?

Karl said  " Intercept the navigation request, verify the assembly is loaded then proceed with the navigation request. If the assembly is not loaded or is in the process of loading, you can wait until the assembly loads, and then proceed with the request. "

Please could you provide some sample code of how to do that since I am not sure how and where to write this code. Would I intercept the navigation in the OnNavigatedTo(NavigationContext navigationContext) of the view model?

P.S. The navigation is working when I use a UserControl in the main app (CodeGenerator). However, it does not work with the module.

Cheers

May 11, 2011 at 9:17 PM

Hi,

Frame Navigation is supported on Prism but there is no sample code like QuickStarts or Reference Implementation or guidance provided out of the box, apart from the one in Karl’s post.

Nevertheless, we will be more than glad to help you if you can provide us a repro sample (for example using SkyDrive) of your solution, and we will try to find out the cause of the issues that you are experiencing.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

May 11, 2011 at 10:23 PM

Hi Miguel,

Thanks a lot for your reply. I really appreciate your help.

I will be prepering a sample to post to my SkyDrive. What is the best way to do it since I use a database and WCF service?

Would that be alright if I remove the database and WCF service and just hard code the views in the module I need to use?

Cheers

Claudio

 

 

Developer
May 12, 2011 at 4:17 PM
Edited May 12, 2011 at 4:18 PM

Hi Claudio,

That would be correct, as long as it does not modify the scenario you're portraying in your sample.

Thanks,

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 13, 2011 at 1:13 PM
Edited May 13, 2011 at 1:24 PM

Hi Miguel, Guido,

Thanks for your help and support.

I have put a sample on my SkyDrive. This is the URL http://cid-ca1406640e48559c.office.live.com/self.aspx/Code/CodeGenerator.zip

Please let me know if you have any problems downloading it.

Also, if you have any questions about the application or if you are having any trouble running it, please let me know so that I can help.

The app contains the following projects:

CodeGenerator
CodeGenerator.Web
CodeGeneratorModule
Prismv4FrameRegionNavigation

In the CodeGeneratorModule I have a file called CodeGenView where I  have 2 Regions definedLeftRegion and MainRegion.

I was using View Discovery before to insert the views into the regions and all was working fine.

In the LeftRegion I have to insert the DetailView and in the MainRegion I have to insert the OptionView.

 <ContentControl x:Name="Details" prism:RegionManager.RegionName="LeftRegion"
                            Style="{StaticResource ContentControlRegionStyle}"
                            VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />

<ContentControl x:Name="Options" prism:RegionManager.RegionName="MainRegion"
                            Style="{StaticResource ContentControlRegionStyle}" VerticalContentAlignment="Stretch"
                            HorizontalContentAlignment="Stretch" />

This is the code I was using before and working:

_container.RegisterType<CodeGeneratorServiceClient>(new InjectionConstructor());
            
_regionManager.Regions[RegionNames.ShellRegion].Add(this._container.Resolve<CodeGenView>());

_regionManager.Regions[RegionNames.LeftRegion].Add(this._container.Resolve<DetailView>());
           
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, () => this._container.Resolve<OptionView>());

When I changed it as per Karl's tutorial, I think something went wrong and the views are not being injected into the regions. But I get no errors here.

container
                .RegisterType<CodeGenViewViewModel>()
                .RegisterType<DetailViewViewModel>()
                .RegisterType<OptionViewViewModel>()
                .RegisterType<Object, CodeGenView>(typeof (CodeGenView).FullName)
                .RegisterType<Object, DetailView>(typeof (DetailView).FullName)
                .RegisterType<Object, OptionView>(typeof (OptionView).FullName);

In my Bootstrapper I prefer to use ModuleCatalog.CreateFromXaml since I do not want to add a reference to the CodeGeneratorModule. However, I have also tried using the code as per Karl's tutorial and added a reference to the moduel but to no avail.

 protected override IModuleCatalog CreateModuleCatalog()
 {
      return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/CodeGenerator;component/ModuleCatalog.xaml", UriKind.Relative));
  }

 protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
 {
     var mappings = base.ConfigureRegionAdapterMappings();
     mappings.RegisterMapping(typeof(Frame), new FrameRegionAdapter(ServiceLocator.Current.GetInstance<IRegionBehaviorFactory>()));
     return mappings;
  }

//protected override void ConfigureModuleCatalog()
//{
  //var moduleInitModuleType = typeof(ModuleInit);
  //this.ModuleCatalog.AddModule(
     // new ModuleInfo
      //{
        //  ModuleName = moduleInitModuleType.Name,
        //  ModuleType = moduleInitModuleType.AssemblyQualifiedName,
        //  InitializationMode = InitializationMode.WhenAvailable,
      //});
//}

In my shell I have 2 hyper link buttons. The HomeView works fine but the link to navigate to the module CodeGenView view does not work. I am not usre if my NavigateUri and UriMapping and MappedUri are correct.

NavigateUri="/CodeGeneratorModule/CodeGenView"
<uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="CodeGenerator.{moduleName}.Views.{pageName}"/>

Border Style="{StaticResource LinksBorderStyle}">
            <StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">
                    <HyperlinkButton Style="{StaticResource LinkStyle}" 
                                     NavigateUri="/HomeView"
                                     TargetName="ContentFrame" Content="home"/>
                        <Rectangle Style="{StaticResource DividerStyle}"/>
                    <HyperlinkButton  x:Name="hlbInventory"  Style="{StaticResource LinkStyle}" 
                                     NavigateUri="/CodeGeneratorModule/CodeGenView"
                                     TargetName="ContentFrame" Content="Code Generator"/>
             </StackPanel>
</Border>

<Border Style="{StaticResource ContentBorderStyle}" Grid.Row="1">
                <navigation:Frame
                x:Name="ContentFrame"
                Style="{StaticResource ContentFrameStyle}" 
                Source="/HomeView
                Navigated="ContentFrame_Navigated"
                NavigationFailed="ContentFrame_NavigationFailed"
                prism:RegionManager.RegionName="MainContentRegion"
                >

                    <navigation:Frame.ContentLoader>
                        <prism_Regions:FrameContentLoader RegionName="MainContentRegion"/>
                    </navigation:Frame.ContentLoader>

                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>

                            <!--Default applicaiton mapper-->
                            <uriMapper:UriMapping Uri="" MappedUri="/CodeGenerator.Views.HomeView"/>

                            <!--Used to view a page-->
                            <uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="CodeGenerator.{moduleName}.Views.{pageName}"/>

                            <!--Used to navigate to a page in the Shell-->
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/CodeGenerator.Views.{pageName}"/>

                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>
            </Border>

I look forward to your reply.

Cheers

Claudio           

 

Developer
May 13, 2011 at 9:22 PM

Hi Claudio,

We've examined your solution and found that the problem you were experiencing was happening because you had set up an incorrect Uri Mapping.

The following mapping:

<uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="CodeGenerator.{moduleName}.Views.{pageName}"/>

had to be changed to this:

 

<uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="/{moduleName}.Views.{pageName}"/>

 

Since when you were registering the type mapping for the CodeGenView in your CodeGenerationModule's ModuleInit, you were using the view's type Full-Name, which is CodeGenerationModule.Views.CodeGenView. However, the mapping tried to get a view from the container with CodeGeneration.CodeGenerationModule.Views.CodeGenView as the contract, thus making the ContentLoader fail to get a view, and return System.Object. 

We've applied that change to the sample you've provided and made it work.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 13, 2011 at 10:08 PM

Hi Guido,

Thanks very much. I really appreciated your help.

Does it mean that I can use my previous code in the module to load the views?

_container.RegisterType<CodeGeneratorServiceClient>(new InjectionConstructor());
_regionManager.Regions[RegionNames.ShellRegion].Add(this._container.Resolve<CodeGenView>());
_regionManager.Regions[RegionNames.LeftRegion].Add(this._container.Resolve<DetailView>());
_regionManager.RegisterViewWithRegion(RegionNames.MainRegion, () => this._container.Resolve<OptionView>());

Also, what is not clear for me is this:

1 - Do I need to have a ViewModel for all the views that participate in the navigation? For example my CodeGenView would not need a ViewModel since it is there only as the parent of my other two views (DetailView and OptionView)

2 - Could you please elaborate a bit more on how the ContentLoader works? How does it load the views? What is the life cycle?

3 -  Karl said in his tutorial:  " Intercept the navigation request, verify the assembly is loaded then proceed with the navigation request. If the assembly is not loaded or is in the process of loading, you can wait until the assembly loads, and then proceed with the request. "

Please could you provide some sample code of how to do that since I am not sure how and where to write this code. Would I intercept the navigation in the OnNavigatedTo(NavigationContext navigationContext) of the view model?

I really would like to understand where to write the code to intercept the navigation request and verify if the assembly is loaded and then proceed with the navigation request.

Cheers

Claudio


May 13, 2011 at 10:13 PM

Sorry,

I forgot to ask when the Views are created?

1 - I was using View Discovery before. Does the navigation library work with View Discovery? 

Cheers

Claudio

May 13, 2011 at 10:18 PM

Sorry again :_)

I had asked this before but I think you might have missed it:

In my Bootstrapper I prefer to use ModuleCatalog.CreateFromXaml since I do not want to add a reference to the CodeGeneratorModule. Can I use this with the navigation library or do I need to have a reference to all the modules in the Silverlight project for it to work?

Thanks

Claudio

May 16, 2011 at 11:14 AM

You dont need references to the modules for navigation to work.

May 16, 2011 at 12:18 PM

Hi gan_s,

You are right. I have just tried it and it works.

Do you know anything about my question number 3? I am struggling to figure out HOW and WHERE to implement what Karl suggested and
would appreciate very much if you could help me.

3 -  Karl said in his tutorial:  " Intercept the navigation request, verify the assembly is loaded then proceed with the navigation request. If the
assembly is not loaded or is in the process of loading, you can wait until the assembly loads, and then proceed with the request. "

Please could you provide some sample code of how to do that since I am not sure HOW and WHERE to write this code. Would I intercept the navigation in the OnNavigatedTo(NavigationContext navigationContext) of the view model?

I really would like to understand where to write the code to intercept the navigation request and verify if the assembly is loaded and then proceed with the navigation request.

Cheers

Claudio

May 16, 2011 at 12:21 PM

Assuming you are downloading a module you download it using a modulemanager.LoadModule. ModuleManager has a DownloadCompleted event (name may not be correct) to which you can hook up to. And in that you can do the regionManager.RequestNavigate. So you navigate only after the module is downloaded. Your module would essentially be another xap in your solution.

May 16, 2011 at 12:59 PM

Thanks gan_s,

However, I was talking about clicking a link in the shell menu (like what the Silverlight navigation template application gives you) using the navigation integration.

Basically, as Karl suggested, before we navigate to a view in a module, we should check if the module is loaded or not and only allow navigation after it is loaded.

If you see his article, it might be clearer what I am trying to explain.

Cheers

C  

 

May 16, 2011 at 1:10 PM
Edited May 16, 2011 at 2:40 PM
That's what even I said. When you navigate you check if module is initialized or not. If not then download it and then navigate to the view. That is where the modulemanager.loadmodule comes into play when you have to download a module. Imoduleinfo has a state property which shows the state of the module. If not initialized then load it.

 

May 16, 2011 at 1:44 PM

I see.

I have never done this before. That is why I am a bit confused.

So, do I check if the module has loaded or not inside the OnNavigatedTo(NavigationContext navigationContext) method? Is this the right place to do it?

Would you have any sample code that you could kindly share?

Cheers

C

 

May 16, 2011 at 2:39 PM

No. You will not do it in the OnNavigatedTo. Here is sample app that I wrote long time back that demonstrates everything you would want to know.

May 16, 2011 at 5:04 PM

Hi gan_s,

Thanks a lot. I will donwload the app right now and have a look.

I really appreciate your help.

Cheers

Claudio

 

May 16, 2011 at 5:20 PM

gan_s,

    Thanks for providing the sample... I was getting ready to post a new thread but seaching for an answer to this issue first and found this one (though the title wasn't particularly related...).    So I've got the same kind of scenario where I have certain module loading on demand and I'd like to use the RegionManager.RequestNavigate to open the views in those modules.    In your example solution and in what I've come up with at the moment, I'm checking whether the module that contains the destination view is already loaded BEFORE calling RequestNavigate... that does work but I'd like something that's more fully integrated with the Navigation pipeline if possible so that I don't end up loading a new module unecessarily in the case that the navigation is cancelled when I finally call RequestNavigate.

Is there someway of overriding either the IRegionNavigationService or the IRegionNavigationContentLoader so that if the destination view isn't found in the container I can inject my logic to request a new module to be loaded at that point?   Thoughts?  Maybe I can handle this with a navigation callback that checks for an error or something...

-James

May 16, 2011 at 5:41 PM

Actually, just played with this a bit and here's a possible approach...   Don't really like the fact that is relies on exception handling for normal operations but might be a lot easier than trying to override the navigation pipeline if there's not an easy extension point.   (the WhenLoaded method below is my own ModuleManager extension method but you get the idea of what it does...

RegionManager.RequestNavigate(RegionNames.PortalMain, navItem.ViewNavigationPath,
      result =>
       {
                if (result.Result != true)
                {
                     if (result.Error is InvalidOperationException)
                      {
                           ModuleManager.WhenLoaded(navItem.ModuleName)
                                 .Subscribe(evt =>
                                   {
                                            RegionManager.RequestNavigate(RegionNames.PortalMain, navItem.ViewNavigationPath);
                                   });
                        }
       }
 });

Essentially... first try navigating without loading the module - this allows navigation to be cancelled WITHOUT unecessarily loading a new module  - if the navigation is NOT cancelled then navigation will fail with an InvalidOperationException and you can then retry the navigation after loading the module and it should suceed...   have only given this about 5 minutes of thought... so please raise any other concerns issues that there may be with this idea.

May 16, 2011 at 6:23 PM

Hi gan_s, jandersen78

I am having problem running the application. I have tried using IIS, IIS Express and cassini but to no avail.

If I run without debugging I get this error:

Server Error in '/mefprism' Application.

The value for the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the 'targetFramework' attribute from the <compilation> element of the Web.config file.

 

If I run with debug I get a pop up saying "Unable to debug. The web server is not configured correctly".

Could you please shed some light on thi?

jandersen78

Could you please provide your  source code including you own ModuleManager extension method. It would be very helpful to me since
I am unsure of how to write an extension mehtod for the ModuleManager.

Cheers

Claudio

May 17, 2011 at 6:52 AM

Go to IIS and change the framework to 4.0. Also set Integrated Widnows Authentication to true.

May 17, 2011 at 6:59 AM

This is as good as checking if module is initialized or not. If not initialized then load the module and then navigate else straight away navigate to the view.

// Hook up t0 modulemanagers LoadModuleCompleted
_moduleManager.LoadModuleCompleted += (s,e) =>
   _regionManager.RequestNavigate(...);

var module = _moduleCatalog.Modules.Single(m => m.ModuleName.Equals("MyModule");
// If module not already loaded then load it
if (module.State != ModuleState.Initialized)
   _moduleManager.LoadModule(module.ModuleName);
else 
  // If module already loaded then just navigate to the view
  _regionManager.RequestNavigate(...);

May 18, 2011 at 5:29 PM

Hi gan_s,

Thanks a lot for your help and source code.

I am a bit confused about how to best use the Library. If I want to use the non linear navigation capability what do I need to change?

In the example Karl used an Inventory module with Item and Category.

What do I have to change to use my own objects?

Cheers

Claudio

 

May 19, 2011 at 9:39 AM

Sorry,

Maybe it is not clear what I meant. Here is an explanation:

I had a look at the source code of Karl's Silverlight demo and I saw the method below. Does it mean I will have to create a method similar to that for my own obejcts to implement non linear navigation?

Please note the Item and Category objects.

protected override void OnContentChanged(object oldContent, object newContent) {
            if (newContent == null)
                this.ContentTemplate = null;
            else if (newContent is Item)
                this.ContentTemplate = ItemDataTemplate;
            else if (newContent is Category)
                this.ContentTemplate = CategoryDataTemplate;
            else
                throw new InvalidOperationException("newContent is unknown data type");
        }

 

May 19, 2011 at 9:41 AM

I havent seen Karl's code/examples. From what I see above this looks like an implementation of a DataTemplateSelector. What has this got to do with prism navigation?

Jan 17, 2012 at 12:13 AM

 

http://blogs.msdn.com/b/kashiffl/archive/2010/10/05/integrating-prism-v4-region-navigation-with-silverlight-frame-navigation.aspx

Mar 2, 2012 at 8:19 AM
gan_s wrote:

No. You will not do it in the OnNavigatedTo. Here is sample app that I wrote long time back that demonstrates everything you would want to know.

Hi gan_s,

I am trying to use Prismv4FrameRegionNavigation framework in Silverlight 4 project. I want to load modules OnDemand.

When my module loading is completed, nothing appears on my region but System.Object text  :- (

 

Please repost your sample application

Thank for your help

Emin

Mar 2, 2012 at 9:02 AM

Is it ok if I send you a link for EOD? If its urgent can you post the bits of your code? i.e.

  • how you have defined a region
  • how you are loading the module
  • how you are loading the view in a region
  • are you using MEF or unity?

in the meanwhile watch this video.

Cheers!

 

 

 

Mar 2, 2012 at 12:11 PM

Yes, if you send me sample application link, may be I will find solution.

I am using Prism 4, Silverlight 4, Unity and Prismv4FrameRegionNavigation framework for navigation( Karl Shifflett code)

I want to load TopologyModule  as OnDemand (Bold at ModuleCatalog.xaml) .This action is trigger from MonitoringManagerMenuModule.



 

  • Defining Region at Shell.xaml
  • <navigation:Frame 
                    x:Name="ContentFrame" 
                    Source="/HomeView" 
                    Regions:RegionManager.RegionName="WorkspaceRegion" 
                    Margin="0,0,0,0"
                    Navigated="ContentFrameNavigated"
                    NavigationFailed="ContentFrameNavigationFailed">
                        <navigation:Frame.ContentLoader>
                            <prism_Regions:FrameContentLoader RegionName="WorkspaceRegion"/>
                        </navigation:Frame.ContentLoader>
                        <navigation:Frame.UriMapper> 
                            <uriMapper:UriMapper>
    
                                <!--Default applicaiton mapper-->
                                <uriMapper:UriMapping Uri="" MappedUri="/MonitoringManager.Views.HomeView"/>
    
                                <!--Used to add a new record-->
                                <uriMapper:UriMapping Uri="/{moduleName}/{pageName}/add" MappedUri="{}{moduleName}.Views.{pageName}?key=0"/>
    
                                <!--Used to edit a record with two keys-->
                                <uriMapper:UriMapping Uri="/{moduleName}/{pageName}/{key1}/{key2}" MappedUri="{}{moduleName}.Views.{pageName}?key1={key1}&amp;key2={key2}" />
    
                                <!--Used to edit a record with only one key-->
                                <uriMapper:UriMapping Uri="/{moduleName}/{pageName}/{key}" MappedUri="{}{moduleName}.Views.{pageName}?key={key}"/>
    
                                <!--Used to view a page-->
                                <uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="{}{moduleName}.Views.{pageName}"/>
    
                                <uriMapper:UriMapping Uri="/{moduleName}/{pageName}" MappedUri="MonitoringManager.{moduleName}.Views.{pageName}"/>
    
                                <!--Used to navigate to a page in the Shell-->
                                <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/MonitoringManager.Views.{pageName}"/>
    
                            </uriMapper:UriMapper>
                        </navigation:Frame.UriMapper>
                    </navigation:Frame>
    

 

  • Loading Module:

        protected override IModuleCatalog CreateModuleCatalog()
        {
            return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/MonitoringManager;component/ModuleCatalog.xaml", UriKind.Relative));
        }
<Modularity:ModuleCatalog 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism.Silverlight" 
    xmlns:sys="clr-namespace:System;assembly=mscorlib">


   
        <Modularity:ModuleInfo 
            InitializationMode="WhenAvailable"
            ModuleName="ServiceAgentsModule" 
            ModuleType="ServiceAgentsModule.Module, MonitoringManagerServiceAgentsModule,Version=1.0.0.0,PublicTocken=null" 
            Ref="MonitoringManagerServiceAgentsModule.xap"/>

        <Modularity:ModuleInfo 
            InitializationMode="WhenAvailable"
            ModuleName="MonitoringManagerMenuModule" 
            ModuleType="MonitoringManagerMenuModule.Module, MonitoringManagerMenuModule,Version=1.0.0.0,PublicTocken=null" 
            Ref="MonitoringManagerMenuModule.xap"/>

        <Modularity:ModuleInfo InitializationMode="WhenAvailable" ModuleName="LoginModule" ModuleType="LoginModule.Module, LoginModule,Version=1.0.0.0,PublicTocken=null" Ref="LoginModule.xap">
            <Modularity:ModuleInfo.DependsOn>
                <sys:String>ServiceAgentsModule</sys:String>
            </Modularity:ModuleInfo.DependsOn>
        </Modularity:ModuleInfo>
   
        <Modularity:ModuleInfo InitializationMode="OnDemand" ModuleName="TopologyModule" ModuleType="TopologyModule.Module, TopologyModule,Version=1.0.0.0,PublicTocken=null" Ref="TopologyModule.xap">
            <Modularity:ModuleInfo.DependsOn>
                <sys:String>ServiceAgentsModule</sys:String>
            </Modularity:ModuleInfo.DependsOn>
        </Modularity:ModuleInfo>
  


</Modularity:ModuleCatalog>
 

  • Loading View in a region

 

   <HyperlinkButton 
                    Content="Topology" 
                    Style="{StaticResource LinkStyle}" 
                    NavigateUri="/TopologyModule/TopologyView" 
                    TargetName="ContentFrame" />

 

thank you for quick response.

Mar 2, 2012 at 1:03 PM
Edited Mar 2, 2012 at 1:04 PM

Hi gan_s

I think my problem source is wrong UriMapper. When I send targetUri to Prismv4RegionFrame.FrameContent Loader ,

it cant load TopologyView, as you can see below