WPF - PageFunctions. Why are they needed?

3.4k views Asked by At

I've been dabbling in WPF for a couple of months now and I've managed to grasp most of what's about and why/when it's used but I'm still struggling to see the value of the PageFunction class.

Can someone give me a simple, but concrete example of when a PageFunction might be the correct tool for the job?

3

There are 3 answers

0
Denis Troller On BEST ANSWER

Mainly, it seems to be a pattern to formalize branching in task based UI.

Let's say you have a form with a checkmark for an optional feature, but this feature requires additional information which is too complicated to fit on the same page. Using this pattern allows delegating information collection to another component.

Moreover, there is kind of a strategy pattern applied, since you could have various subsystems able to collect the same information, all of them inheriting the PageFunction(of T), so that the code actually calling those does not need to know any detail about it.

Those are just some ideas, I have not exactly looked into it.

0
Nicolas Dorier On

PageFunction in a page = Dialog box in desktop application (without Page).

You can use a PageFunction every time you use a dialog box in a desktop application and that you want to develop a webnavigation-like behavior to your program.

0
Paul Stovell On

The main thing page functions enable is implementing workflows with sub-tasks and managing the return stack.

If you just rely on page-to-page navigation, it's hard to pause the current navigation path, do something else, and then come back and continue. PageFunctions enable that through the concept of Returning and unwinding the navigation stack.

I provided some real world examples of this here: http://www.paulstovell.com/wpf-navigation