Understanding XAML Schemas And Namespace Declarations.

XAML is actually a flavor of XML, so in order to work with XAML, we need to follow its schema. Schema is like an agreement between both the producer and consumer of XML, so they can work together in case you want to read that schema.

Whenever you create a new UWP Application in Visual Studio, you will find some namespaces in the designer code of XAML. UWP stands for Universal Windows Platform. Go to solution explorer and open MainPage.xaml. You'll find the following lines of code in the tag of <page----></page> of your application. These are different schema and namespaces used in UWP applications. Now we're going to explore these namespaces one by one.

XMAL

In the very first line you can find your class name which is in fact your application name with MainPage. Below it you'll find few namespaces like:

  • :x
  • :local
  • :d
  • :mc

These are the namespaces that are used for different purposes. Le's explain each one-by-one --  and one more thing before starting, that URL which you're watching here are not URLs, in fact. They are UR, which stands for Uniform Resource Indicator. URI is used to define a namespace that we can use further in our document of the app.

  1. xmlns = " http:/schemas.microsoft.com/winfx/2006/xaml/presentation "

    This schema defines all UI ( User Interface ) components like button, textblock, etc.

  2. xmlns : x = " http://schemas.microsoft.com/winfx/2006/xaml "

    All of the rules of XAML in general are defined at this schema. From rules you can assume that rules which have to be followed while writing UI in XAML.

  3. xmlns : local = " using: --- name of application --- "

    This is a local namespace. You can reference your own local classes here by using this namespace in application.

  4. xmlns : d = "http://schemas.microsoft.com/expression/blend/2008 "

  5. xmlns : mc = " http://schemas.openxmlformats.org/markup-compatibility/2006 "

    xmlns : d and xmlns : mc are the schemas used to represent the design view of application. Design view is the designer area of application.

  6. mc : Ignorable = " d "

    If you want to ignore some namespace on runtime, put that namespace in double quotes as here " d " will be ignored on runtime that has been defined already on the fourth line. This option exists here because of xmlns : mc namespace.

That is all. It is my first ever attempt to write a blog. Please provide feedback so that I'll improve my writing and be able to share further stuff better.

Next Recommended Reading What is XAML