23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 7-1 Examples of flyout controls from the <strong>HTML</strong> flyout control sample.<br />

I’ll again encourage you to read the Guidelines and checklist for Flyouts topic that goes into detail<br />

about how and when to use the different designs that are possible with this control. It also outlines<br />

when not to use the control: for example, to surface errors not related to user action (use a message<br />

dialog instead), for primary commands (use the app bar), for text selection context menus, and for UI<br />

that is part of a workflow and should be directly on the app canvas. These guidelines also suggest<br />

keeping a flyout small and focused (omitting unnecessary controls) and making sure a flyout is<br />

positioned close to the object that invoked it. Let’s now see how that works in the code.<br />

Note In addition to apps that display a WinJS.UI.Flyout on their own, some system APIs (such as that<br />

to create a secondary tile) create a system flyout. In these cases, the app will receive a blur event, which<br />

will cause any light dismiss app bars to be dismissed. To prevent this, set the app bar to sticky when<br />

using those APIs.<br />

WinJS.UI.Flyout Properties, Methods, and Events<br />

Most of the properties, methods, and events of the WinJS.UI.Flyout control are exactly the same as<br />

we’ve already seen for the app bar. The show and hide methods control its visibility, a hidden property<br />

indicates its visible state, and same the beforeshow, aftershow, beforehide, and afterhide events fire as<br />

appropriate. The afterhide event is typically used to detect dismissal of the flyout.<br />

Like the app bar, the flyout also has a placement property, but it has different values that are only<br />

meaningful in the context of the flyout’s alignment and anchor properties. In fact, all three properties<br />

are optional parameters to the show method because they determine where, exactly, the flyout appears<br />

on the screen; the default placement and alignment can also be set on the control itself because these<br />

294

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

Saved successfully!

Ooh no, something went wrong!