Silverlight名称空间问题 [英] Problem with Silverlight NameSpace

查看:148
本文介绍了Silverlight名称空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个问题

1.在XAML中,为什么在特定名称之前或之后在xmlns名称空间关键字(例如..
)之后使用x:.

xmlns:x ="http://abc"



<矩形x:name ="abc" xmlns:x =#unknown">

================================================== =========

2.为什么XAML中的名称空间是一些以http://开头的网址,以及为什么不是某些标识符,例如C ++中的使用名称空间myNameSpace"

为什么我们在XAML中使用以"http://"

Two Questions

1. In XAML, why do we use x: before a specific name or after the xmlns namespace keyword like..


xmlns : x = "http://abc"

and

<rectangle x:name="abc" xmlns:x="#unknown">

===========================================================

2. why the namespace in XAML is some web address starting with http:// and why not some identifier like in C++ as "using namespace myNameSpace"

why do we have namespace in XAML something starting with "http://"

推荐答案

开头的名称空间?对于第一个问题,x是名称空间的前缀(〜alias),其中可以在xaml中使用.有关更多信息,请参见例如: http://msdn.microsoft.com/en-us/library/ms747086 .aspx [^ ]

不知道第二个问题的实际原因,但我猜是因为语法符合XML名称空间声明.但是,并不总是使用以http开头的名称空间.例如,如果您在当前项目中引用名称空间,则语法是不同的.例如:
For the first question, x is a prefix (~alias) for the namespace which can be used in the xaml. For more info see for example: http://msdn.microsoft.com/en-us/library/ms747086.aspx[^]

Don''t know the actual reason for the second question, but I''d guess it''s because the syntax conforms the XML namespace declaration. However, namespaces starting http aren''t always used. For example if you refer to a namespace in the current project, the syntax is different. For example:
xmlns:MyNamespace="clr-namespace:MyProject.Controls;assembly=MyProject">


Nika回答了第一个问题;我正在回答第二个.

命名空间模式"http://"不是特别来自XAML,而是来自XML.原因是可能通过名称空间的世界唯一性来创建世界唯一性标识符(XML标签,属性).可以基于实际存在的URL创建XML名称空间.由于我们的世界具有Internet权威组织分层提供的唯一域名系统,因此每个公司或其他组织都会获得一个或多个世界唯一的域名.组织通过其网站支持URL后面的URL部分,因此任何人都可以找到与XML名称架构具有相同URL的资源.

在XML内部,名称空间由唯一前缀(别名)表示,唯一性由XML解析器控制.前缀本身具有单个XML文档的范围,但是相应的名称空间可以是世界唯一的.此层次结构使每个基于名称空间的XML标识符世界唯一,可以验证.

对于.NET命名空间,不需要这样的名称空间的世界唯一性.相反,程序集本身可以通过字符串命名机制获得几乎"唯一的名称,但这已经是一个完全不同的故事了……

—SA
Nika answered first question; I''m answering the second one.

The namespace schema "http://" comes not from from XAML specifically, but from XML. The reason is the possibility of creation of world-unique identifiers (XML tags, attributes) through world uniqueness of the name space. The XML name space can be created based on really existing URL. As our world has the system of unique domain names provided hierarchically by Internet authority organization, every company or other organization gets one or more world-unique domain names. The part of URL after domain name is supported by the organization via its Web site, so anyone can locate the resource having the same URL as the XML name schema.

Inside the XML, name spaces are denoted by the unique prefix (alias) and the uniqueness is controlled by the XML parser. The prefix itself has the scope of a single XML document, but the corresponding namespace can be world unique. This hierarchy makes every namespace-based XML identifier world-unique, which can be validated.

As to .NET namespaces, such world uniqueness of name spaces is not required. Instead, the assemblies themselves can get "almost" unique names through the mechanism of string naming, but this is already quite a different story…

—SA


这篇关于Silverlight名称空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆