HTML and CSS Reference
In-Depth Information
This isn't a problem for the storeDetails.html page because it is loaded only once and
never removed from the document. In this case, I am using the WinJS page feature only so that
I can decompose my Metro app into self-contained pieces to make development and mainte-
nance easier. As you can see in Listing 3-18, I display the storeDetails.html page just once,
meaning that I can expect the code in my callback to be executed just once as well.
Listing 3-18. Displaying the Page
function performInitialSetup(e) {
WinJS.UI.processAll().then(function () {
UI.List.displayListItems();
UI.List.setupListEvents();
UI.AppBar.setupButtons();
UI.Flyouts.setupAddItemFlyout();
ViewModel.State.bind("selectedItemIndex", function (newValue) {
var targetElement=document.getElementById("itemDetailTarget");
WinJS.Utilities.empty(targetElement)
var url=newValue == -1 ? "/html/noSelection.html"
: "/pages/itemDetail/itemDetail.html"
WinJS.UI.Pages.render(url, targetElement);
});
WinJS.UI.Pages.render("/html/storeDetail.html",
document.getElementById("storeDetailTarget"));
});
}
The final step is to update the layout element in default.html , as follows:
<div id="bottomRightContainer" class="gridRight">
<h1 class="win-type-xx-large">Store Detail</h1>
<div id="storeDetailTarget"></div>
</div>
The result is that selecting an item on the main list will display the home page of the rel-
evant store, as shown in Figure 3-5 .
Checking Manifest Permissions
Metro applications are subject to a security sandbox. To obtain access to external content, your
application must be granted one or more permissions in its manifest file. To ensure you have
the access you need, open the package.appmanifest file from the Solution Explorer and go to
the Capabilities tab.
You will see a list of capabilities that you can request. These are presented to the user when
they view your app in the Metro Store so that they can make an informed choice about what
access they grant to your application. (Well, that's the theory; in practice, users don't generally
pay attention to these declarations until an app does something that surprises them.)
 
Search WWH ::




Custom Search