I have trouble getting navigation working using Prism 4.
I've set up a test solution in which I have a shell with a region called MainRegion
:
<Window x:Class="PrismNavigationTest.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://www.codeplex.com/prism"
Title="ShellView" Height="350" Width="525">
<Grid>
<ContentControl prism:RegionManager.RegionName="MainRegion"/>
</Grid>
</Window>
Next I have a bootstrapper that adds a Module
that is located in a different project to my modulecatalog
:
protected override void ConfigureModuleCatalog()
{
Type module = typeof(Module.ModuleInit);
ModuleCatalog.AddModule(new ModuleInfo("Module", module.AssemblyQualifiedName));
base.ConfigureModuleCatalog();
}
In the Initialize method on the ModuleInit
class I'm trying to change the view of the mainregion
.
public class ModuleInit : IModule
{
private IUnityContainer container;
private IRegionManager regionManager;
public ModuleInit(IUnityContainer container, IRegionManager regionManager)
{
this.container = container;
this.regionManager = regionManager;
}
public void Initialize()
{
// TODO This works
//regionManager.RegisterViewWithRegion("MainRegion", () => container.Resolve<View>());
// TODO This doesn't work
container.RegisterType<object, View>("View1");
regionManager.Regions["MainRegion"].RequestNavigate(new Uri("View1", UriKind.Relative));
}
}
Using view discovery works but not view injection.