我有点厌烦每个XAML文件都必须声明一个XML命名空间,并且必须为我的自定义控件使用前缀。是否可以将clr命名空间映射到"http://schemas.microsoft.com/winfx/2006/xaml/presentation"?
我在我的AssemblyInfo.cs中尝试了以下内容:
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation","MyOwnNamespace")]
但这似乎不起作用。我仍然会收到编译错误,如下所示:
“标签'MyCustomControl'在XML命名空间'http://schemas.microsoft.com/winfx/2006/xaml/presentation'中不存在。”
注意:我的控件在同一个程序集中(我只有一个程序集)。
local:
更短的前缀不是一个选项吗?我知道我曾经在某个时候这样做过,并使用了l:
代替,因为那个长前缀看起来很丑。 - Botz3000l:
肯定比local:
更方便。我可能会使用它。谢谢。 - Eren Ersönmezxmlns
声明。这是个人意见,但它使得从哪个命名空间引用控件更加透明。 - Kcvin