A damn at han's Windows Phone Book notes (2: Flashlight)

Source: Internet
Author: User

Add application bar

It is intuitive to use expression blend.

Add application bar: Right-click the phoneapplicationpage on the objects and Timeline panel and select Add ApplicationBar.

Add applicationbariconbutton: Right-click ApplicationBar and select Add applicationbariconbutton.

Add applicationbarmenuitem: Right-click ApplicationBar and select Add applicationbarmenuitem. (The following uses iconbutton as an example. menuitem is similar to this one)

Attribute panel of applicationbariconbutton:

Name. The search column is used to search for attributes. However, the attributes of applicationbariconbutton are too few and are displayed below.

Many built-in Button icons can be found in the iconuri drop-down box ,... You can customize the icon file path.

Text is: Touch the right... When the icon button is displayed, the introductory text below each icon is displayed.

To add an event, select the Panel on which lightning is located in the upper-right corner and double-click it in the text box next to click.

 

Setting one by one is troublesome. Therefore, use a loop to bind the click events of each menu item:

Using Microsoft. Phone. Shell; Make applicationbarmenuitem visible

Foreach (applicationbarmenuitem menuitem in this. ApplicationBar. menuitems)
{
Menuitem. Click + = new eventhandler (applicationbarmenuitem_click );
}

In applicationbarmenuitem_click, convert the sender type to applicationbarmenuitem to get different attribute values.

Author'sCodeThe interface iapplicationbarmenuitem is used instead of the specific applicationbarmenuitem class. The reason is that Microsoft's WP team is more flexible for future expansion, but we don't need to care about it here.

 

Applicationbariconbutton Initialization

The applicationbariconbutton control cannot be initialized only when it is in XAML.

// Assign application bar buttons to member fields, because this cannot be done by initializecomponent:
This. sosbutton = This. ApplicationBar. Buttons [0] As applicationbarmenuitem;
This. strobebutton = This. ApplicationBar. Buttons [1] As applicationbarmenuitem;

 

In the source code of the author, all images are stored in the images directory. However, when you use blend to add images, the icons directory is automatically created. Therefore, it is better to put images in the icons directory.

 

The MessageBox of Windows Phone is simplified. There are only two buttons, and the button text cannot be customized. To customize MessageBox, Microsoft. xNa. Framework. gamerservices is required. For details, see page 58.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.