Wednesday, April 30, 2014

Windows Phone 8 First Application : Sample

Windows Phone 8 First Application : Sample
I have created first sample application with two TextBox ,TextBlock and  Button. Enter the value .

Create new project and open the filename.xaml file.

add the UI elements from toolbox

TextBox - enter the values
TextBlock -  Is like a label
Button - Handling the listener
filename.xaml
<phone:PhoneApplicationPage
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"
xmlns:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"
x:Class="PhoneApp2.MainPage"
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>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="First Application" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="iamvijayakumar" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="14,0,10,0">
<TextBox HorizontalAlignment="Left"  Name="password" Margin="94,164,0,0" VerticalAlignment="Top" Width="319" />
<TextBlock HorizontalAlignment="Left"  Margin="135,25,0,0" TextWrapping="Wrap" Text="Login Page" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Name="username" Height="72" Margin="94,87,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="319" />
<TextBlock HorizontalAlignment="Left" Name="resulr_textblock" Margin="94,258,0,0" TextWrapping="Wrap"  VerticalAlignment="Top"/>
<Button Content="Ok" HorizontalAlignment="Left" Margin="94,393,0,0" VerticalAlignment="Top" Click="Button_OK"/>

</Grid>
</Grid>


</phone:PhoneApplicationPage>
filename.cs 

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 PhoneApp2.Resources;

namespace PhoneApp2
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();

}

private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
{

}

private void Button_OK(object sender, RoutedEventArgs e)
{
String userN = username.Text.ToString();
String secondname = password.Text.ToString();
resulr_textblock.Text = "Welcome :: " + userN + secondname;
}
}




}
Output 


No comments:

Post a Comment