Handling Hub Section Navigation

If you want to do something when someone clicks on the header for Section A or Section B then you can handle the Hub control’s headerinvoked event. For example, you could handle this event and navigate the user to a new page with more detailed content for the section.

I discuss creating multipage apps and navigation in detail in Chapter 12, “Page Fragments and Navigation.” Here, I just want to show you how you can handle the headerinvoked event and determine which section was clicked.

In Listing 4.15, the headerinvoked event is handled and the selected hub section index and header name is written to the Visual Studio JavaScript Console window.

LISTING 4.15 Using Hubs and Hub Sections (hub\hub.html)

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.