The problem here is that WPF encompasses well over a dozen namespaces (all of
which start with System.Windows). If each .NET namespace had a different XML namespace,
you??™d need to specify the right namespace for each and every control you use, which quickly
gets messy. Instead, the creators of WPF chose to combine all of these .NET namespaces into
a single XML namespace. This works because within the different .NET namespaces that are a
part of WPF, there aren??™t any classes that have the same name.
The namespace information allows the XAML parser to find the right class. For example,
when it looks at the Window and Grid elements, it sees that they are placed in the default WPF
namespace. It then searches the corresponding .NET namespaces, until it finds System.Windows.
Window and System.Windows.Controls.Grid.
The Code-Behind Class
XAML allows you to construct a user interface, but in order to make a functioning application
you need a way to connect the event handlers that contain your application code. XAML
makes this easy using the Class attribute that??™s shown here:
1
The x namespace prefix places the Class attribute in the XAML namespace, which means
this is a more general part of the XAML language. In fact, the Class attribute tells the XAML
parser to generate a new class with the specified name.
Pages:
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125