-
Notifications
You must be signed in to change notification settings - Fork 0
Namespaces
A XAML file usually declares a default XAML namespace in its root element.
This default namespace defines elements that can be declared without qualifying them by a prefix (e.g. x:
).
XAML namespaces apply only to the specific element on which they are declared and its children, which explains why they are typically placed on the root element.
ref
Most XAML files have two xmlns
declarations
-
xmlns
maps a default XAML namespace
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml
xmlns:x
maps a separate XAML namespace for XAML-defined language elements to the x:
prefix:
- x:Name uniquely identified object elements for access to the object from code-behind :point_right: x:Name attribute
- x:Key sets a unique key for each resource in a ResourceDictionary 👉 x:Key attribute
-
x:Class specifies the CLR namespace and class name for the class that provides code-behind
for a XAML page. The x:Class directive configures XAML markup compilation to join partial classes
between markup and code-behind. In this example it can be seen how it refers to the
MainPage
class within theProject
namespace. 👉 x:Class directive
Language elements are commonly used features necessary for Windows Runtime apps.
For example, to join any code-behind to a XAML file through a partial class, you must name that class as the x:Class
attribute in the root element of the XAML file.
// C#
namespace Project
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
...
}
}
<!-- XAML -->
<Page
x:Class="Project.MainPage"
...>
...
</Page>
mc:
indicates and supports a markup compatibility mode for reading XAML.
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
- Newtonsoft.Json
- System.Random
- System.Threading
- System.Threading.Tasks
- Windows.Foundation
- Windows.Storage
- Windows.UI.ViewManagement
- Windows.UI.Xaml.Markup
- Dependency properties
- Markup extensions
- Namespaces
- Resource dictionaries
- SplitView
- Page ?
- Type conversion
- Grid ?
- StackPanel ?
- RelativePanel ?
- VariableSizedWrapGrid
- Canvas