【发布时间】:2015-08-19 06:18:41
【问题描述】:
我有两个类似的项目。一个是 Silverlight 项目,另一个是 WPF。它们都包含一些命名空间和大量自定义用户控件。
由于控件分布在许多命名空间中,因此在使用它们时,我必须定义相当多的命名空间。于是我开始define the XML namespaces in the AssemblyInfo.cs:
[assembly: XmlnsPrefix("http://ui.example.com/xaml/touch", "cui")]
[assembly: XmlnsDefinition("http://ui.example.com/xaml/touch", "example_ui.controls")]
[assembly: XmlnsDefinition("http://ui.example.com/xaml/touch", "example_ui.themes")]
现在我只需要在每个文件中定义一个命名空间:
xmlns:cui="http://ui.example.com/xaml/touch"
不幸的是,这仅在 Silverlight 中有效。我的问题是,如何让它在 WPF 项目中工作?
在 WPF 项目中出现如下错误:
Error 5 The tag 'LookUpField' does not exist in XML namespace
'http://ui.example.com/xaml/touch'. Line 7 Position 14. D:\src\prototype\lookup-control\lookup-control\MainWindow.xaml 7 14 lookup-control
【问题讨论】:
-
您对 WPF 和 Silverlight 使用相同的程序集吗?也许 WPF 不能使用 Silverlight 控件
-
不,我已经将此作为一个最小示例进行了测试。两个项目,一个silverlight和一个wpf。无论如何,它们都没有链接。两者都有自定义用户控件和显示方式。
-
我说的是帖子中的实际项目,因为我想给这个问题一个背景/背景。
标签: c# xml wpf xaml silverlight