23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Our good friend the <strong>HTML</strong> AppBar control sample again delivers an example of custom layout, in<br />

Scenario 5. In html/custom-layout.html we see the markup for a custom top app bar containing<br />

arbitrary elements:<br />

<br />

<br />

<br />

<br />

<br />

<br />

Page Title<br />

<br />

<br />

<br />

Admittedly, the result of this example is a little odd—it creates a navigation bar with a typical page<br />

header with a back button where each control might have a focus rectangle. I don’t recommend<br />

following this design!<br />

As mentioned in the “Tips and Tricks” section in Chapter 4 (under “Control Styling”), you can<br />

suppress the focus rectangle with a :focus { outline: none; } rule in <strong>CSS</strong>. To remove it from<br />

the back button, for example, you can add the style to the following rule in css/custom-layout.css:<br />

.win-appbar header .win-backbutton {<br />

margin-left: 39px;<br />

margin-top: 59px;<br />

outline: none;<br />

}<br />

Notice again how this rule and the others in css/custom-layout.css all use the win-appbar class as a<br />

base selector but only because it’s styling other generic classes like header and win-backbutton. If you<br />

use specific classes in your app bar or navigation bar, you really don’t need the win-appbar selector at<br />

all.<br />

To implement a navigation bar like that of Internet Explorer or the Weather app, you can certainly<br />

use a ListView control along with item templates or custom item rendering functions, where you’d wire<br />

up itemInvoked events to WinJS.Navigation.navigate and so forth. Again, there’s nothing particularly<br />

special or complicated here: with a custom layout, the app bar is really just a flyout container for other<br />

<strong>HTML</strong> elements.<br />

292

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!