I am struggling with passing navigation parameters between 2 views in a WPF PRISM application.
The basic structure of my application is as follows: I have a viewmodels folder, inside that I have a folder for every "section" of my application simply to help structure things logically ie. Orders, Projects
The same applies for Views.
I am navigating from a view in the orders folder to one in the Projects folder.
The actual navigation is working and the application hits a breakpoint in my constructor for the second viewmodel, however the INavigationAware interface methods are never called.
I am not sure if this has something to do with the views/viewmodels existing in different namespaces due to the folders?
Here is the important code snippets I use:
Bootstrapper
Container.RegisterType(typeof(Object), typeof(ConfirmOrders), "Orders.ConfirmOrders");
Container.RegisterType(typeof(Object), typeof(QuotedCosts), "Projects.QuotedCosts");
Navigation To QuotedCosts from ConfirmOrders
NavigationParameters par = new NavigationParameters();
par.Add("ProjectID", ProjID);
_regionManager.RequestNavigate("ContentRegion", "Projects.QuotedCosts", par);
QuotedCosts viewmodel whos Navigation Events never get called
public class QuotedCostsViewModel : ViewModelBase, INavigationAware
{
private IProjectService _projectService;
private int ProjectID { get; set; }
public mProject CurrProject { get; protected set; }
public QuotedCostsViewModel(IProjectService projectService)
{
_projectService = projectService;
CurrProject = _projectService.GetProjectDetails(ProjectID);
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
ProjectID = int.Parse(navigationContext.Parameters["ProjectID"].ToString());
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
}