JumpStart with XAML in UWP

April 11, 2016
3 mins read

If you want to leverage your existing knowledge of creating user interfaces and doing so in Visual Studio, and apply that towards creating Universal Windows Platform apps. Did you notice how similar it was to creating WPF and ASP.Net Web Forms? That was no accident. It’s a very similar experience and a very similar workflow. And as a result, it’s just as fun, and it’s just as easy, and while there is a lot to learn, there’s certainly nothing to be intimidated about.
There are several options for designing the user interface of your application.
First, by dragging and dropping controls from the Toolbox onto the design surface, resizing those controls and positioning them on the design surface.
Second, by the Properties window. That can be used to modify the various attributes of the controls that we see on the designer surface. However, I think you’re going to find that, just like HTML, a visual designer won’t give you the level of control that you’re really going to want over the various properties and how they relate to each other.
Third, and the awesome way is to be done by XAML editor. Here you can get the full command of your application interface and build the most precise interface.
So, there is really no way around learning the actual XAML syntax itself.
Furthermore, just like ASP.NET Web Forms and WPF applications, every page has a code behind file that’s associated with it where we can write event handler code in C#. We see that same relationship between the MainPage.xaml and the MainPage.xaml.cs in Windows 10 apps.
In fact, in the MainPage.xaml.cs, you can see that we’re in the namespace “JumpStartWithXAML” and we’re creating a class called MainPage, notice that it says “partial class“.
 
Using the keyword partial allows developers to create multiple class definitions and all have them be partial definitions of a single class, stored in different files. But as long as that file has the same class name, and is in the same namespace, and it has the keyword “partial”, we can create many different files to represent a single class.
Notice that this MainPage derives from an object called Page. If we were to hover over, you can see that this is a class called Windows.UI.XAML.Controls.Page.
 
If you go to the MainPage.xaml, and look here at the very top, notice here that we’re working with a Page object and notice that the class name is also HelloWorld, namespace, MainPage, class.
The MainPage.xaml and MainPage.xaml.cs are two different files that represent the same class.
One of these files represents the class from a visual perspective (i.e. MainPage.xaml).
And The other represents it from a behavioral aspect (i.e. MainPage.xaml.cs).

Note: During Windows 10 App Dev you can use all the debugging tools. You can set break points, step line-by-line through code, evaluate property values, variables, etc. as the application is running.

You also have so many different emulators available in debug mode. Not only do they emulate the different screen sizes and resolutions, but they also emulate different memory constraints for the different phone hardware available today. So we can test our application in a low memory environment or test our application in a high memory environment, as well as screen resolutions and sizes.
So you can control your App interface upon every interface by making your XAML compatible for every screen.
You can see that there’s a Grid used in the page template for MainPage.xaml. These are called Layout Controls, they’re very important to the adaptive story of Universal Windows Platform apps. Layout controls allow a single code base to be utilized across many different devices of device form factors.
The Universal Windows Platform API provides this rich collection of visual controls that work across all Windows devices. They allow input via mouse in some cases, or via finger in other cases. But that same API also provides us with thousands of methods across hundreds of classes of namespaces that allow you to do really cool stuff with your application.
For example, if you need to access the Internet to go retrieve some sort of resource, or if you want to work with a file on the file system, whether it be on a phone, or a tablet, or a desktop, or even the Xbox. Or if you want to play a media file, like a song or a video, there are methods in the UWP API, that make all of those things possible and a lot more.
These the layout and visual qualities of controls may need to change based on the screen size of the device they’re running on. Creating adaptive triggers allows me to modify the layout and the scale of items in our application based on the size of the screen. Again, this will be another topic that I’ll be demonstrating often throughout this series because it too, is one of the most important new features available in the Universal Windows Platform.
XAML allows us to layout controls on our app’s forms. XAML is not specific to the Universal Windows Platform; it’s been around for about a decade now. But building a Universal Windows Platform app really all starts with a fundamental understanding of the XAML language and how to mold it and shape it to do what we want it to do for our application. So, learning XAML is number one and we will start that in the very next lesson.

Data Scientist & Solution Architect || IBM Recognised Speaker, Mentor, and Teacher || Debater || Blogger || Guinness World Record Holder || Watson Solution Developer || IBM Community Activist || Aspiring to Inspire.

Leave a Reply

Your email address will not be published.

Previous Story

IBM Watson: Coping with Humans – A Support Group for Bots

Next Story

Microsoft Imagine Cup: An Awesome Journey With Full of Pressure and Anxiety.

Latest from Blog

Quantum Computing | What, Why & How

Now as we are starting the 5th decade after the very first proposed model in the 1980s, quantum computers are now commercially available, brought out of the lab, and into the industry by IBM Quantum. With many experts predicting it will revolutionize the way we approach problem-solving. With the recent

Case Study: Digital Transformation of “justSajid Bank”

In this current era of what we call “digital first”, industries are repeatedly changing and evolving with the help of technology. So as the banking industry is reshaping itself, banks need to keep adopting positive changes to counter and overcome the key challenges of the modern world to overcome the

Metaverse || A Whole New World.

Things are going to be super dramatic in the next few years. Metaverse is going to open a lot of new doors to revise things that we are doing now. The culture and lifestyle would be changed. Some new cultures would have emerged and everybody would be living without physical

Pakistan Day 2020 | Coronavirus Technical Solutions

Well, on Pakistan Day 2020 our nation along with the rest of the world is facing Corona Pandemic. As the sons of this great motherland, we are trying to play our roles at our places. Within the last few weeks, Alhamdulillah I’ve got a chance to develop two technical solutions

Password: Choose the Secure, Easy and Cool Password

A super secure Password is very common nowadays. Although according to experts the password is going to expire very soon. Moreover, the pin codes are also replacing password in some why. Perhaps still there is a lot of importance of a secure password in many places. The one of the most

JumpStart with DevOps

What is DevOps; DevOps is a Software Development Strategy, that bridges the gap between the Dev and the Ops side of the company. * It’s not a tool, it’s a Methodology to bridge the gap b/w development and operations teams! As there is always a lot of conflicts between the

JumpStart Programming with Python 3

Motivation; Well, if you want to play with data and deal with complex analytics problems then Python is the best for you. We can use Python for developing complex scientific and numeric apps. Python is designed with features to facilitate data analysis and visualization. The syntax in Python helps the programmers to do coding

Understanding of Data Science Methodology

Motivation: It’s all about the different methods used in data science. Data Science Methodology: There is the following methodology used in data science which can further categories into different phases; From Problem to Approach Business Understanding Analytical Approach Working with Data Data Requirements Data Collection Data Understanding Data Preparation Deriving the

Understanding Machine Learning Methodology

Motivation Well, if we talk about a human cell sample extracted from a patient. The cell would have some characteristics. One of the interesting questions we can ask, what kind of statistics that cell have? One could easily presume that only a doctor with years of experience could diagnose a tumor and

SIMPLE NAVIGATION IN WINDOWS APPLICATION

The Navigation of UWP Apps is extremely cool and easier than other platforms. It allows enabling a variety of intuitive user experiences for moving between apps, pages, and content. Navigation is the key part of the Application. In your small Apps, you may maintain your contents and functionality in a

UNDERSTANDING THE ARCHITECTURE OF UNIVERSAL WINDOWS PLATFORM

The architecture of Universal Windows Platform is most exclusive with the center of gravity which is One Windows Core. Now the whole development will follow the common refactored core that will common for all the windows Releases. It’s all about One Core, One Hardware Platform, Universal Hardware Driver and Standalone

Guinness World Record Holder | Hajj Hackathon | Khadim Al-Haramain Al-Sharifain

Khadim Al-Haramain Al-Sharifain Built an MVP of a cognitive platform name “Khadim Al-Haramain Al-Sharifain“.  Objective The objective was to facilitate Hajj operations by introducing cognitive services integrated with Hajj systems. Hence millions of Muslims who are there for Allah Rab-ul-Izat, can perform anything without disturbing their focuses and concentrations.  Functionalities

JumpStart with IBM Bluemix

IBM Bluemix is the world most exclusive cloud platform that provides developers to quickly develop, Deploy and manage Apps over the cloud without dealing with any underline infrastructure. Bluemix provides great open source platforms for your needs. Tech experts believe that up to 2020 the computing era would completely change.

JumpStart Into Big Data With HDInsight

What would happen when the volume of your data increased repeatedly over time and you need high velocity at the same time. Not only that but you have a different variety of data and Variability also exists in your data. So how would you handle all that data? If we

Microsoft SharePoint: Create an Intranet in SharePoint

As you should already have some hands on with SharePoint. So, Lets do some hands on with SharePoint Intranet for Small company. Simply start with a Blank Site Collection. Let’s assume that the company has 3 Departments: Sales, Production and Support. They each have their own area in which they should

.NET Core

.NET Core 1.0  .NET Core 1.0 is a major new investment in the future of .NET and laying the foundation for decades to come. Still, it is in its early stage, and for some time you might still focus .NET Framework 4.6 depending on your application needs. But for many scenarios,

JUMPSTART WITH DATA BINDING IN UWP

Data Binding is one of the most interesting topics in Universal App Development. In order to perform the better functionality, you really need to have some great usage of Data Binding in you Apps. So! First thing first. What is actually the Data Binding and is its usage in UWP.

justSajid | A PLACE FOR MY THOUGHTS

This blog is my personal mental playground. The views expressed are mine, and mine alone. They do not represent the views of my employer, my family, my friends, my imaginary friends, my neighbors, people who live in my city, province, country, region, or planet, nor do they represent the views

justSajid | A PLACE FOR MY THOUGHTS

justSajid is my personal mental playground. The views expressed are mine, and mine alone. They do not represent the views of my employer, my family, my friends, my imaginary friends, my neighbors, people who live in my city, province, country, region, or planet, nor do they represent the views of

Agentic AI: The Future of Machines Acting with Purpose

Artificial Intelligence (AI) has come a long way from being a fancy algorithm for chess games to becoming our digital assistant, creative collaborator, and even a philosopher’s muse. One of the more intriguing advancements in AI is Agentic AI—an AI system that can act autonomously, pursue goals, and make decisions,
GoUp