如何为XAML创建自己的(非CLR!)XML命名空间?
注意Telerik名称空间。它不是如何为XAML创建自己的(非CLR!)XML命名空间?,xml,wpf,xaml,Xml,Wpf,Xaml,注意Telerik名称空间。它不是clr名称空间:Telerik;assembly=Telerik如您所料。他们是怎么做到的 <UserControl x:Class="Sandbox.MyUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/200
clr名称空间:Telerik;assembly=Telerik
如您所料。他们是怎么做到的
<UserControl x:Class="Sandbox.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
</UserControl>
您可以使用
XmlnsDefinition
属性将一个或多个CLR命名空间映射到URI;例如:
[assembly: XmlnsDefinition("http://www.yourdomain.com/schema", "MyProject.Foo")]
[assembly: XmlnsDefinition("http://www.yourdomain.com/schema", "MyProject.Bar")]
[assembly: XmlnsDefinition("http://www.yourdomain.com/schema", "MyProject.Baz")]
您还可以使用xmlnprefix
属性为命名空间关联默认前缀:
[assembly: XmlnsPrefix("http://www.yourdomain.com/schema/", "foo")]
请注意,此属性仅用作编辑工具的建议。将其作为答案发布。使用基于URI的架构有什么好处?抱歉,如果我偏离了原来的主题。@LawrenceA.conterras,它允许您为几个CLR名称空间声明一个XML名称空间。如果您知道给定组件位于库中,则不需要记住它在哪个CLR命名空间中声明。