Thursday, May 8, 2014

How Create ApplicationMenu in Windows 8 Mobile Example

How Create ApplicationMenu in Windows Phone 8 Example

This post about how to create  ApplicationBarMenu .
Windows 8 mobile provide great user interface and Menu items. the class called ApplicationBarMenuItem.
I have created simple layout with menu item and i gave on click Function for menu item click.

1.I have created two menu items
main.xaml class

<phone:PhoneApplicationPage
x:Class="VjFirst.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Button" HorizontalAlignment="Left" Margin="134,156,0,0" VerticalAlignment="Top" Click="Button_Click_2" />

</Grid>

</Grid>
<phone:PhoneApplicationPage.ApplicationBar>

<shell:ApplicationBar IsVisible="True" Mode="Default" Opacity="1.0" IsMenuEnabled="True" >
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem  Text="Vj Blog" Click="ApplicationBarMenuItem_Click_1"></shell:ApplicationBarMenuItem>
<shell:ApplicationBarMenuItem Text="Vj Windows 8 Blog" ></shell:ApplicationBarMenuItem>
</shell:ApplicationBar.MenuItems>

</shell:ApplicationBar>


</phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>


OutPut







CS Code



using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using VjFirst.Resources;

namespace VjFirst
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button Clicked");
}

private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
{
MessageBox.Show("Menu Button Cliecked");
}

}

}






No comments:

Post a Comment