Monday, 15 April 2013

c# - How to navigate using prism for multiple views in Module -



c# - How to navigate using prism for multiple views in Module -

i'm new prism need help on navigation between views in project have 4 views, have created view in 1 module. have created shell , bootstrapper. need is, need pass info 1 view another(for eg, first view has list of employees, select 1 employee , click button details of employee). i'm using viewmodel first approach`

_container.registertype<dashboardview>(); _container.registertype<preparerunview>(); _container.registertype<idashboardviewviewmodel, dashboardviewviewmodel>(); _container.registertype<ipreparerunviewviewmodel, preparerunviewviewmodel>(); _regionmanager.registerviewwithregion(regionnames.mainregion, typeof(dashboardview)); _regionmanager.registerviewwithregion(regionnames.mainregion, typeof(preparerunview)); in case how do navigation between views , pass data? what need specify in module class initialize function?

moreover in module class when register both views same region, i'm able see both views, need activate , deactivate views also.

thanks in advance

the view-model of first view (the 1 select employee) needs reference prism's iregionmanager object. navigate sec view , pass info follows, much querystring values in url:-

var uriquery = new uriquery(); uriquery.add("empid", "123"); // add together more name/value pairs if wish! var viewname = "your_view_name" + uriquery; _regionmanager.requestnavigate("your part name", viewname);

as can see, navigate view specifying view name. work, need register views under name ioc container (how depends on container use).

in view-model of view navigating to, implement inavigationaware interface:-

public bool isnavigationtarget(navigationcontext navigationcontext) { homecoming true; } public void onnavigatedfrom(navigationcontext navigationcontext) { } public void onnavigatedto(navigationcontext navigationcontext) { // called whenever view navigated to. // extract querystring value(s). var employeeid = navigationcontext.parameters["empid"]; .. etc.. }

c# wpf navigation prism

No comments:

Post a Comment