BrowsingContainer.Handler CanNavigateBack

Developer
Jul 13, 2010 at 8:10 AM

Hello Mr. nRoute :),

I’ve a master/details thing like in the Netflix demo. Selecting something in the master list triggers navigation in the details. Also, the details itself has some “links” that trigger navigation within it, like so (an ASCII art picture is worth about nine words :)):

 PartnerList   ->    Partner Details -> Addresses

^^^^^^^^      ^^^^^^^^^^^^^^^^^^^^^^^

   List                Details browsing container

The “special” requirement is that the “Back” button should only appear when navigating within the details and so, for this whenever the master selection changes I use a PurgeNavigationJournalAction after a NavigateAction, while when navigating from within the details I don’t purge anything. HOWEVER, doing this I found that when navigating inside the details the “Back” button didn’t show, although it should’ve.

So debugging I came to the fact that even though the details container HAD one page in the _backStack (which was the original PartnerDetails described above), because the condition in its CanNavigateBack() method was “_backStack.Count > 1” it wouldn’t be able to navigate back to it. So I changed the condition to “_backStack.Count >0” and now it works, navigating back requests the “Partner Details” url and all is well… unless I’m missing something ;)

Note that in the netflix sample it works "out-of-the-box" because there is always a "null" element first in the _backStack (which I'm not sure is correct in itself). Also, there's no purging involved there, if it were, then it looks like it would break.

What do you think?

Thanks!