PRISM View Injection/Navigation in Same Module

Posted by Jeaffrey Gilbert on Stack Overflow See other posts from Stack Overflow or by Jeaffrey Gilbert
Published on 2010-05-27T05:50:29Z Indexed on 2010/06/01 5:43 UTC
Read the original article Hit count: 310

Filed under:
|
|

This is ModuleInit.cs in Products module

public class ModuleInit : IModule
{
    private readonly IUnityContainer _container;
    private readonly IRegionManager _regionManager;

    public ModuleInit(IUnityContainer container, IRegionManager regionManager)
    {
        _container = container;
        _regionManager = regionManager;
    }

    #region IModule Members
    public void Initialize()
    {
        App app = (App)Application.Current;
        _regionManager.RegisterViewWithRegion(RegionNames.ModuleRegionProducts, () => _container.Resolve<Views.ProductsCycle>());
    }
    #endregion
}

Below is button event handler in ProductsCycle.cs to go to another view still within same module:

private void btnForward_Click(object sender, RoutedEventArgs e)
    {
        IRegion productsRegion = _regionManager.Regions["ModuleRegionProducts"];

        var productsListView = _container.Resolve<Views.ProductsList>();
        productsRegion.Add(productsListView, "ProductsList");

        productsRegion.Activate(productsListView);
    }

State: ProductsCycle page is successfully loaded on first load.

Problem: View doesn't changed from ProductCycle page to ProductsList page when btnForward is clicked.

I'm using Silverlight 4 and PRISM2. Please your advice, thank you.

© Stack Overflow or respective owner

Related posts about c#

Related posts about silverlight-4.0