How to Create a “Hello World” app in C# and XAML
This
is my first project in creating an application for the Windows phone 8.0 and Windows
desktop. I used the universal blank
Windows application in Visual Studio 2015 Community to create this and followed
the tutorial step by step. You could
look this tutorial up on Microsoft at https://msdn.microsoft.com/library/windows/apps/dn765018.aspx
entitled
Create a “Hello, world” XAML.
It’s a great way to get started to
learn how to make Windows apps for the phone or desktop.
After
I studied the code, I tweaked it to make it more personal just by changing the
text. I intend to more changes as I get
to know the SDK and XAML more in depth.
What
I learned from this experience?
I
learned by just by getting your hands a little dirty by messing around with
code and practicing, it can be a great learning experience. I eventually want to develop more complicated
apps, but I need to take it at a slower pace and not rush into things. I want to get a foundation of C# and making
excellent and productive applications by getting down the basics first. Just remember the cultivation of a plant
needs good nutritious soil and without good soil it’s not going to grow
properly. The same applies to learning
how to program, without grasping the basics of the C# language you can’t get
far. I wish I was a pro, but I’ll get
there one project at a time.
Copy of source code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
//
The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace HelloEveryone
{
/// <summary>
/// An empty page that can be used on its own or navigated to
within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void Button_click(object sender, RoutedEventArgs e)
{
greetingOutput.Text = "Hello " +
nameInput.Text + "!";
}
}
}
XAML syntax code:
<Page
x:Class="HelloEveryone.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HelloEveryone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel x:Name="contentPanel"
Margin="8,32,0,0">
<TextBlock Text="Hello, Everyone!" Margin="0,0,0,40"/>
<TextBlock Text="This is my first project creating a simple
app." Margin="0,0,0,40"/>
<TextBlock Text="What's your name?"/>
<StackPanel x:Name="inputPanel"
Orientation="Horizontal" Margin="0,20,0,20">
<TextBox x:Name="nameInput" Width="280"
HorizontalAlignment="Left"/>
<Button x:Name="inputButton"
Content="Say "What's going
on!"" Click="Button_click"/>
</StackPanel>
<TextBlock x:Name="greetingOutput"/>
</StackPanel>
</Grid>
</Page>
No comments:
Post a Comment