Windows Mobile Hello World App

In this walk through I'll create, build and run a simple Hello World application in C#. I am using Windows 10 , Visual Studio 2013 and Hyper-V.

1. Create a new project as shown below. - File -> New-> Project (Ctrl+Shift+N) I am using .NET Framework 4.5






2. Add TextBox (txtBox), TextBlock (txtBlock) and Button
 

3. XAML Code for above UI


 
<Page
    x:Class="WindowsPhoneEx1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WindowsPhoneEx1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
 
    <Grid>
        <Button Content="Click Me" HorizontalAlignment="Left" Margin="10,49,0,0" VerticalAlignment="Top" Click="Button_Click" Height="57"/>
        <TextBlock x:Name="txtBlock" HorizontalAlignment="Left" Margin="10,102,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="44" Width="380" FontSize="20"/>
        <TextBox x:Name="txtBox" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="380" Background="{ThemeResource AppBarBackgroundThemeBrush}" BorderBrush="{ThemeResource AppBarItemDisabledForegroundThemeBrush}" PlaceholderText="Input your text here" Height="44" MaxLength="40"/>
 
    </Grid>
</Page>


4. Double Click on Button and add this code in click event and add async keyword after private keyword.

[Async Improves Responsiveness] https://msdn.microsoft.com/en-us/library/hh191443.aspx


    private async void Button_Click(object sender, RoutedEventArgs e)
        {
            txtBlock.Text = txtBox.Text;
            await new MessageDialog(txtBox.Text).ShowAsync();
        }



 5.Run the application.


Full source code here

Comments