Share via


Understanding XAML Schemas and namespace Declarations ( UWP Apps )

XAML is actually a flavor of XML, so in order to work with XAML, we need to follow its schema. Schema is like a agreement between both producer and consumer of XML, so they can work together. In case if you want to read that schema.
Whenever you create a new UWP Application in Visual Studio. You 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 that uses in UWP applications. Now we're going to explore these namespaces one by one.


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

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

These are the namespaces that are used for different purposes. Lets explain each one by one. And one more thing before starting, those URLs which you're watching here are in fact not URLs. They are URI which stands for Uniform Resource Indicator. URI used to define namespace that we can use further in our document of 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 that 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, you can put that namespace in double quotes as here " d " will be ignored on runtime that has been defined already on 4th line. This option exists here because of xmlns : mc namespace.** ** 

This is all. It is my first ever attempt to write an article. Sorry for poor English. English is not being my mother tongue. Please provide feedback so that I'll improve my writing and be able to share further better stuff.