This project is read-only.

BrowsingContainer, Clear Back Pages?

Aug 2, 2010 at 3:04 AM
sometimes when i navigate a view in a browsingContainer, i just want this view to be the first view in this BrowsingContainer, which means clear all the existing Back Pages in the browsingContainer, how to do this? thanks!!!
Aug 2, 2010 at 12:03 PM

Mrijou, it's really very easy - use the PurgeNavigationJournalAction behavior. Under the hood this behavior relies on the ISupportJournalPurging interface, that is any container that implements ISupporJournalPurging can have it's journal purged using the behavior and the BrowsingContainer does implement ISupportJournalPurging. 

Hope that helps,

Aug 18, 2010 at 6:45 AM

thanks,it works!  but another problem occurs.

i use the NavigateBackInfoBehavior from the nRoute's Netflix example. 

in the app's main menu:

<Button x:Name="btnSectionTopic" Style="{StaticResource ToolbarButtonStyle}" >
                                    <Image Source="Images/section_1.png" Stretch="Fill"/>
                                    <i:EventTrigger EventName="Click">
                                        <nRoute:PurgeNavigationJournalAction HandlerName="LeftBrowsingContainer"/>
                                        <nRoute:NavigateAction Url="Views/Wq_AssessSchemeListView/"></nRoute:NavigateAction>      

in the Click event ,first i use the PurgeNavigationJournalAction, but i find it don't trigger the "private void UpdateContent()" in NavigateBackInfoBehavior at the same time,

so it cause some problem to the state of my "Back" button which Attached to my BrowsingContainer.

<Button  Content="Back" Style="{StaticResource ButtonStyle}">
                                <behaviors:NavigateBackInfoBehavior BrowsingContainer="{Binding ElementName=LeftBrowsingContainer}"/>

Aug 19, 2010 at 12:23 PM
Hi, well I think you'll need to extend NavigateBackInfoBehavior to listen for when journals are purged. In the Netflix demo we didn't purge so I never bothered to check for it, but, it's very simple to do as ISupportJournalPurging has a JournalPurged event. So basically listen to when journal are purged and accordingly update the back button's state. Cheer, Rishi
Aug 24, 2010 at 8:34 AM

thanks!!! i just extend NavigateBackInfoBehavior like this:

private void UpdateContainer(IBrowsingContainer oldContainer, IBrowsingContainer newContainer)
            if (oldContainer != null) oldContainer.Navigated -= new EventHandler<NavigatedEventArgs>(Container_Navigated);
            if (newContainer != null) newContainer.Navigated += new EventHandler<NavigatedEventArgs>(Container_Navigated);
            if (oldContainer != null) oldContainer.JournalPurged -= new EventHandler<NavigationContainerEventArgs>(Container_JournalPurged);
            if (newContainer != null) newContainer.JournalPurged += new EventHandler<NavigationContainerEventArgs>(Container_JournalPurged);

private void Container_JournalPurged(object sender, NavigationContainerEventArgs e)

i find something strange.   when i click the "btnSectionTopic" after some navigation operation.

but i find the code excutes like this: 

first into the "Container_JournalPurged=>UpdateContent()=> and this.BrowsingContainer.BackPagesJournal = 0, everything is ok.

then  into "Container_Navigated=>UpdateContent()=>at this time, the Url = "Views/Wq_AssessSchemeListView/", but  this.BrowsingContainer.BackPagesJournal = 1, and  it's the last Url i just navigated before,  the this.BrowsingContainer.CanNavigateBack = false, 

how this happens? 

Aug 25, 2010 at 1:47 PM

Well, it might be related to this

My thinking about this is/was that once you populate the journals and then purge, it should still have one item in it - the current item hence the > 1. However, this might be leading to some issues, so I'm gonna dive into this a bit more and get back to you. In the meanwhile, If you building against nRoute's source, try changing _backStack.Count >0.