Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prism RequestNavigate does not work

Tags:

wpf

prism

In each view

public partial class View2 : UserControl, IRegionMemberLifetime, INavigationAware
{

  public bool KeepAlive
  {
    get { return false; }
  }

  bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
  {
    return true;
  }
  void INavigationAware.OnNavigatedFrom(NavigationContext navigationContext)
  {
    // Intentionally not implemented.
  }
  void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
  {
    this.navigationJournal = navigationContext.NavigationService.Journal;
  }

}

Initialize:

container.RegisterType<object, View1>("View1");
container.RegisterType<object, View2>("View2");

regionManager.RequestNavigate("Window1", new Uri("View1", UriKind.Relative));
regionManager.RequestNavigate("Window2", new Uri("View2", UriKind.Relative));

I am following the developer guide, it does not change the view if view exists.

like image 308
viewer20q Avatar asked May 08 '11 02:05

viewer20q


1 Answers

Are you sure the view gets populated by the container?

I would suggest you to provide a callback for the RequestNavigate method, so you'll be able to track what happens with your view thru the NavigationResult:

regionManager.RequestNavigate
(
    "Window1",
    new Uri("View2", UriKind.Relative),
    (NavigationResult nr) => 
    {
        var error = nr.Error;
        var result = nr.Result;
        // put a breakpoint here and checkout what NavigationResult contains
    }
);
like image 189
Shimmy Weitzhandler Avatar answered Sep 24 '22 14:09

Shimmy Weitzhandler