2010-12-28 30 views
1

私は1つのアセンブリのXAMLは、AssemblyInfo.csに登録されている:私は、ユーザーコントロールに名前空間を使用する場合はWPF:XAML名前空間

namespace SWC.ViewModels 
{ 
    public class MenuViewModel 
     : ObservableCollection<MenuViewModel> 
    { 
     public MenuViewModel() 
      : base() 
     { 
     } 
    } 
} 

[assembly: XmlnsDefinition("http://schemas.mysite.es/wpf", "SWC.ViewModels")] 

そして、私の名前空間で

が、私はこれらのクラスをHACE 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

ようこそスタックオーバーフロー!書式設定のヒント:コードブロックを取得するには、各行の先頭に4つの空白を付けるか、 '{}'ボタンをクリックします。 –

答えて

1

customMenuコントロールが存在するアセンブリを指定する必要があると思います。アセンブリは、プロジェクトから参照する必要があります(参照セクションの)。

xmlns:customMenu="clr-namespace:customMenuNamespace;assembly=customMenuLibrary" 

そうでなければ、私は、コンパイラは唯一の「http://schemas.mysite.es/wpf」を通して、あなたの実装を見つけることができますどのように表示されません。そのアドレスには何がありますか? 2つのマイクロソフトのスキーマ

http://schemas.microsoft.com/winfx/2006/xaml/presentation 
http://http://schemas.microsoft.com/winfx/2006/xaml 

xamlコンパイラのいくつかの識別子のように動作しますが、これらのアドレスには何もありません。