Reference article (this article mainly refers to some content in the reference article. You need to learn more about ApplicationBar. You can view the connection article ):
Windows phone 7 toolbar (ApplicationBar) -- http://www.cnblogs.com/xiaogeer/archive/2012/04/12/2444093.html#commentform
Windows phone (26) ApplicationBar application bar -- http://www.cnblogs.com/shenzhoulong/archive/2012/05/14/2498230.html ps: the example is to implement a simple player
1)ApplicationBar Introduction
The toolbar (ApplicationBar) is defined in "Microsoft. phone. in the Shell namespace, the toolbar buttons (ApplicationBarIconButton) and toolbar menu (ApplicationBarMenuItem) are used. Each ApplicationBar can have up to four applicationbariconbuttons, but the ApplicationBarMenuItem can have more than four.
<phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.check.rest.png" Text="cancel" Click="ApplicationBarIconButton_Click"/> <shell:ApplicationBarIconButton IconUri="/Images/dark/appbar.cancel.rest.png" Text="ok"/> <shell:ApplicationBar.MenuItems> <shell:ApplicationBarMenuItem Text="MenuItem 1" Click="ApplicationBarMenuItem_Click"/> <shell:ApplicationBarMenuItem Text="MenuItem 2"/> </shell:ApplicationBar.MenuItems> </shell:ApplicationBar> </phone:PhoneApplicationPage.ApplicationBar>
ApplicationBarIconButton is a circle-style button, and ApplicationBarMenuItem is a vertical text menu.
2)ApplicationBar Attribute-Text & IconUri
The two important attributes of ApplicationBarIconButton are Text and IconUri. Text is the Text format and string type, while IconUri is the Uri type. Generally, it is a relative path pointing to an image resource. This image has strict requirements. The overall size is 48*48, and the central image area (for example, the right icon area) is 26*26. It is recommended that the background be transparent, which is greater than 48*48, the display range of ApplicationBar is exceeded, and the image area is greater than 26*26, which is beyond the circle. The Ampersand and errors are icons, and the circle does not belong to the icon and is an element in ApplicationBar. As long as ApplicationBarIconButton is added to the ApplicationBar, the circle is displayed, however, whether the icon is displayed depends on whether the set IconUri is correct or not. If an error occurs, the default error icon is displayed. Ps: the size of the wp8 image is 76*76, and the proportion of the image in the center area is approximately 41.167*41.167. You can adjust the size of the center image area as needed.
If you only want to learn, you do not have to create the ApplicationBarIconButton icon by yourself. If you have installed and developed the windows phone 7.1SDK, some default icons will be copied to your computer and C: \ Program Files \ Microsoft SDKs \ Windows Phone \ v7.1 \ Icons. Do you see the dark and light folders? These are the ApplicationBarIconButton Icons that come with the system, applicable to the dark and light themes (set the topic: "set"-> "topic"-> "background "). Ps: wp8 can be viewed in v8.0.
The IconUri image is correctly displayed in bar; the IconUri image is incorrectly displayed in bar.
3) ApplicationBar Attribute-ForegroundColor & BackgroundColor
The most interesting attributes of ApplicationBar are ForegroundColor and BackgroundColor. ForegroundColor is the color on the value button, and BackgroundColor is the background color of the entire ApplicationBar. Some people may say that this is not necessary, I can only say that you have misunderstood, buddy. I cannot tell clearly, this must be used with IconButton images, especially transparent images. Set ForegroundColor = "Blue" BackgroundColor = "Green" to use transparent images in the dark folder.
Ps: icons are divided into light & dark themes. In view of the fact that the icons in the light folder are black, the icons in the dark folder are transparent-you can use a set of icons and transparent images under the dark topic. Q: If you try to add the colors under the light and dark themes to the wp8 project, no matter which theme will automatically change to the Qianjiang color, the icons under the light theme will not appear.
4) ApplicationBar-controls a single button of ApplicationBarIconButton
In xaml, <shell: ApplicationBarIconButton x: Name = "appbarButton" IconUri = "/Images/xx.png" Text = "xx"/>, you can use appbarButton = (ApplicationBarIconButton) this. applicationBar. buttons [0.
(ApplicationBarIconButton) this. ApplicationBar. Buttons [0]). IsEnabled = false; -- you can change it to appbarButton. IsEnabled = false;
Similarly, you can operate various attributes of appbarButton to control a single button.