开发者

Silverlight XAML - does the XMLNS actually go external?

When you create a new silverlight page, you get a number of xml namespaces auto created in the user control tag. Eg -

<UserControl x:Class="QuickStart.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d"
   d:DesignHeight="300" d:DesignWidth="400">

I know that xmlns has the core silverlight tags, :x has xaml language elements, :d has expression blend stu开发者_运维问答ff etc. My question is this - does silverlight actually make a call to the defined schema UIs either during design or run-time? I can't imagine that it is going out to schemas.microsoft.com every time it renders a page. But if not, are the URIs effectively just constants?


XML namespaces are URLs, but in most cases, they don't correspond to actual websites, or documentation or anything. They basically serve to provide a unique identifier for XML elements, as long as everyone cooperates an uses a domain name that they own as part of the URL. In the early days, whoever came up with using URLs for xmlns's may have intended for people to post documentation at the URLs, but nobody really does that.

XML parsers do not visit these URLs at any point, they are basically just identifiers.


No, it does not go out to microsoft.com (those folders don't even exist), and yes, that makes these basically constants.


Your question has already been answered, but nobody mentioned why they are used.

Not mentioned is that you can also specify a namespace via an assembly reference, but that would mean you would need one namespace per assembly. The Silverlight libraries are spread out over multiple assemblies (more than just the example xmls entries above indicates).

Using a "constant" as you rightly call them as the namespace means that multiple assemblies can be referenced with a single shared namespace.

This saves on a large number of separate xmlns entries, but does introduce the problem of figuring out what assemblies a namspace refers to if you only have the page source :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜