Application bar
In the process of application development, we often need to use an additional menu bar. In WP7, Microsoft provides us with good support in this aspect-ApplicationBar.
By default, ApplicationBar uses the color of the system theme (white and black), which is changed accordingly when the system theme is changed. The ApplicationBar supports a maximum of four icon buttons and a maximum of five sub-items in the menu bar. When more than nine icons are used, we need to consider whether the design is reasonable. Some icons of WP7 can be used in the icon button. You can also make them if they cannot meet your needs, but pay attention to consistent style.
ApplicationBar can be generated through XAML. When a page is created, a part of the annotated code is automatically generated. Canceling the annotation is the ApplicationBar in XAML. We can modify it as needed.
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
ApplicationBar does not inherit from frameworkelement, so it does not support binding. To change the font type or font size during runtime, you must use C # code to generate ApplicationBar for control.
ApplicationBar = new ApplicationBar ();
ApplicationBar. isvisible = true;
ApplicationBar. ismenuenabled = true;
Applicationbariconbutton btnadd = new applicationbariconbutton (New uri ("/icons/icons1.png", urikind. relativeorabsolute ));
Btnadd. Text = "add ";
ApplicationBar. Buttons. Add (btnadd );
Applicationbarmenuitem itemadd = new applicationbarmenuitem ();
ApplicationBar. menuitems. Add (itemadd );
Horizontal and vertical screen support
The WP7 application can develop horizontal or vertical screens, but cannot force change the screen direction through code.
During the development process, we can change supportedorientations to change the screen support.
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
Supportedorientations supports portraitorlandscape, landscape, and portrait. The default value is portrait. You can change the initial orientation of the screen through orientation.
When the screen direction changes, the program layout often does not meet the original design intention. We need to use the orientationchanged event for corresponding processing.
OrientationChanged += new EventHandler<OrientationChangedEventArgs>(SecondPage_OrientationChanged);
Hiding system pallets
In the development process, we may need to maximize our program, which requires that we can hide the system tray, and we can change it through code.
this.SetValue(SystemTray.IsVisibleProperty, !(bool)this.GetValue(SystemTray.IsVisibleProperty));