To Create a Windows 10 App using C#;
Let’s Create a Universal Windows App in Microsoft Visual Studio;
In the template Selection, check the Empty Project and chick OK;
Microsoft Visual Studio will create some files for you in Solution Explorer;
Now click upon MainPage.xaml, you will get the screen here;
You will see the Desing View along with its predefice XAML markups on that screen. That environement is set for you by Visual Studio hence you can only concentrate upon the work which you want to do…
As UWP is the app with one code that run on all Windows devices, you you can run your code on all the devices. So if you run the application you’ll see the blank screen;
:: The MainPage consists of two files that have extensions of “.xaml” and .xaml.cs! The XAML is stands for Extensible Application Markup Language (XAML). It is a declarative language. Used to define User Interface. All the Modern Windows 10 UI is based upon XAML.
Microsoft Visual C# always associate with the XAML file or User Interface Definition. C# file stay behind as the Code Behind File with the file extension “.cs”. This is where you put the logic of your application!
Now Back to the XAML file and create a visual control by either Toolbox or by code.
- Create TextBlock by using code or by dragging from Toolbox.
Now to come to the property explorer, you will get everything to customize the text block!
- So here at property explorer we change the Text in the common category and change the text property inside the Text category.
- Now run the application and you will get the output.
Now Let’s check our C# code. In the logical file of write some code to display some text against TextBlock;
txtHello.Text = “Hello from C#!”;
And now when we run the application, it will show us output from that;
So as you observed, the value we’re sending from our logical C# code is over riding the value that we set in our XAML code!
As UWP App can run on all windows devices, so let’s test our App over the Windows 10 Phone Emulator;
So that’s how we can develop a UWP through Visual C#!