简体   繁体   中英

navigation and how to register the view with the region?

I have two views between which I want to navigate on button click and they are registered with a region on module initialization like this:

public class ModuleTaxCalc : IModule //PRISM MODULE POWER
{
    IUnityContainer container;
    IRegionManager regionManager;


    public ModuleTaxCalc(IUnityContainer container, IRegionManager regionManager)
    {
        this.container = container;
        this.regionManager = regionManager;

    }

    public void Initialize()
    {

        container.RegisterType<ICustomer, Customer>();

        //container.RegisterType<object, ViewA>("ViewA");
        //container.RegisterType<object, ViewB>("ViewB");
        regionManager.RegisterViewWithRegion("TaxCalculatorRegion", typeof(ViewA));
        regionManager.RegisterViewWithRegion("TaxCalculatorRegion", typeof(ViewB));

    }


}

My issue is that the 'ViewA' gets visible automatically when application starts/

if I do this instead:

 public void Initialize()
        {

            container.RegisterType<object, ViewA>("ViewA");
            container.RegisterType<object, ViewB>("ViewB");


        }

then both views are invisible and become visible only on button click, but I guess they are not registered with the region in this case.

For navigation, you want to register the views for navigation and then navigate to them.

// register the view
container.RegisterTypeForNavigation<ViewA>();

// and some time later, show it in the region
regionManager.RequestNavigate( "TaxCalculatorRegion", "ViewA" );

If you register the view with a region instead, it will be automatically displayed in that region (View Discovery). Much more detailed info is available in the Prism documentation ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM