Monday, May 5, 2014

Windows Mobile 8 MessageBox Example

Windows Mobile 8 MessageBox Example
Today we are going to see how to show validation message on buttonclick Windows 8 mobile
Windows Mobile 8 they called MessageBox. I have created simple app with button and button onclick it will show MessageBox.

  MessageBox.Show("Button Clicked");

main.xaml
<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>

</phone:PhoneApplicationPage>


CS class

i have created button click method in CS class. then called button click method in button click

private void Button_Click_2(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button Clicked");
}



<Button Content="Button" HorizontalAlignment="Left" Margin="134,156,0,0" VerticalAlignment="Top" Click="Button_Click_2" />

Output




No comments:

Post a Comment