tags:

views:

495

answers:

2

I have a Page which is loaded inside a Frame element via it's Source property. I need to get access to the Frames .BackStack property from the source xaml's code-behind... Is that possible?

so roughly the code is -

<Frame x:Name="contentFrame" Source="ProjectsPage.xaml"/>

in the ProjectsPage.xaml.cs i want to access properties on its parent frame.

+1  A: 

If you use NavigationService.GetNavigationService and pass in an element from within ProjectsPage, you can access things like CanGoBack and GoBack on your Frame's NavigationService that let you accomplish almost as much as having the BackStack itself.

Robert Macnee
+1  A: 

Navigation history is one area in which WPF is sorely deficient. No, I don't believe there's any way to get at the BackStack of the Frame from the page. You could implement a bit of a hack, if you don't need to do this generically. Hook the navigation events of the Frame, and set an attached dependency property to the Frame on any DependencyObject that's navigated to. Unfortunately, there's not much you can do with the BackStack, but I assume you've already determined it's good enough for what ever you're doing.

wekempf
Yup, pretty much found that navigation history is somewhat difficult to use and probably not really intended to be used in the way i had envisaged. Took some work but i ended up implementing my own Journal instead. It turned out to be the easiest option.
Stimul8d