How to stop Navigate when error raised?

Topics: Prism v4 - WPF 4
Feb 21, 2012 at 2:29 PM

I want to Check authorization before load the view. if no authorization, the view will not show.

I use below code, it just show error message, but not to stop show the view



  private void NavItemDoubleClick(object navItem)
            if (navItem == null) return;
            NavMainMenuInfo item = navItem as NavMainMenuInfo;
            if (string.IsNullOrEmpty(item.ViewName))
            this.regionManager.RequestNavigate(RegionNames.DocumentRegion, new Uri(item.ViewName, UriKind.Relative),


        private void NavigationCompleted(NavigationResult result)
            if (result.Error != null)
            IsBusy = false;


    public void OnNavigatedTo(NavigationContext navigationContext)
            if(!(Csla.Rules.BusinessRules.HasPermission(Csla.Rules.AuthorizationActions.GetObject, typeof(Unit))))
                throw new Exception("...");

            if (this.Model == null)
                IsBusy = true;
                BeginRefresh(callback => UnitList.GetAll(callback));

Feb 23, 2012 at 7:40 PM


Based on my understanding, the OnNavigatedTo method is invoked after the view has been constructed, injected in the region and activated. Based on this, it seems that you are checking the "authorization" to show the view after the view was already shown. You can find more information about the navigation sequence in the following section of the Prism documentation:

As a possible approach you could check if the user has authorization to see the view before performing the navigation request and if the the view must not be shown, the view RequestNavigate method is not invoked. Regarding this approach, I believe you could find the following thread useful, where a similar concern is being discussed:

I hope you find this useful,

Damian Cherubini