我在AssemblyInfo.cs中注册了一个程序集XAML:
[assembly: XmlnsDefinition("http://schemas.mysite.es/wpf", "SWC.ViewModels")]
在我的命名空间中,我会看到这些类:
namespace SWC.ViewModels
{
public class MenuViewModel
: ObservableCollection<MenuViewModel>
{
public MenuViewModel()
: base()
{
}
}
}
如果我在用户控件XAML中使用命名空间,
<UserControl x:Class="SWC.UserControls.UserMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:customMenu="http://schemas.mysite.es/wpf">
我可以在我的XMLNS名称空间中使用该类,
<UserControl.Resources>
<customMenu:MenuViewModel x:Key="MenuItemsSource">
但是,当我执行应用程序时,编译器说
The label 'MenuViewModel' dosen't exist in the namespace XML 'http://schemas.mysite.es/wpf'
全部,可以帮助我?我对这个问题感到很疯狂!! 最好的问候,
答案 0 :(得分:1)
我认为您需要指定存在customMenu控件的程序集。还必须从项目中引用程序集(在“参考”部分中)。
xmlns:customMenu="clr-namespace:customMenuNamespace;assembly=customMenuLibrary"
否则我看不到编译器如何只能通过“http://schemas.mysite.es/wpf”找到你的实现。那个地址是什么?两个微软架构
http://schemas.microsoft.com/winfx/2006/xaml/presentation
http://http://schemas.microsoft.com/winfx/2006/xaml
像xaml编译器的某些标识符一样工作,这些地址没有任何内容。