Skip to Content
Professional Visual Basic 2012 and .NET 4.5 Programming
book

Professional Visual Basic 2012 and .NET 4.5 Programming

by Bill Sheldon, Billy Hollis, Rob Windsor, David McCarter, Gastón Hillar, Todd Herman
January 2013
Intermediate to advanced
912 pages
26h 58m
English
Wrox
Content preview from Professional Visual Basic 2012 and .NET 4.5 Programming

Implementing Contracts

Early in the chapter, we discussed interaction with charms on the start bar. Those interactions are handled in your app by implementing the appropriate contracts. There are several contracts your app can implement, with Search and Share being the most important.

Saying that a contract is “implemented” sounds like implementing an abstract interface, but in fact many contracts are implemented merely by taking two steps:

1. Declare that the app will work with the control by changing the Package.appmanifest item in the project.
2. Handling an event at the application level to find out when the user selected the charm associated with the contract.

Let's step through a very simple case for working with the Search charm. This is by no means a full search implementation; it just shows the minimum code to detect when a Search has been requested and then do something in the UI.

First, start a new app with the Blank App template, and name it SearchContractExample.

To declare support for the Search contract, open the Package.appmanifest item in the project and go to the Declarations tab. It has a drop-down for the various declarations, and the Search contract is in the list. Figure 13.23 shows the Declarations page, with the list of available declarations dropped down.

Figure 13.23 The Package.appmanifest Declarations page, showing the drop-down of declarations. The Search contract declaration is selected in the drop-down.

To declare support for a Search contract, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Visual Basic 2012 Programmer's Reference

Visual Basic 2012 Programmer's Reference

Rod Stephens

Publisher Resources

ISBN: 9781118332139Purchase book