2009-03-10 52 views
1

私はW3CErrorOrWarningのオブジェクトをWPFウィンドウのコントロールにバインディングしています。.NET WPF XAMLネームスペースのEnum型のマッピング

プロパティの1つが「タイプ」という名前です。これは単純な列挙型であるタイプのW3CErrorOrWarningTypeです:

 
Enum W3CErrorOrWarningType 
    ValidationError 
    ValidationWarning 
End Enum 

私はこの方法でそれを使用しようとしている...

<Window ... 
     xmlns:enums="clr-namespace:WpfApplication1.XhtmlTextBox.W3CValidator.W3CResponse.W3CErrorOrWarning" 
     ... /> 
    ... 
    <DataTemplate> 
     <Image Name="TypeIcon" ... /> 
     <DataTemplate.Triggers> 
      <DataTrigger Binding="{Binding Type}"> 
       <DataTrigger.Value> 
        <enums:W3CErrorOrWarningType> 
         ValidationError 
        </enums:W3CErrorOrWarningType> 
       </DataTrigger.Value> 
       <Setter TargetName="TypeIcon" 
         Property="Source" 
         Value="images/Error.png"/> 
      </DataTrigger> 
      <DataTrigger Binding="{Binding Type}"> 
       <DataTrigger.Value> 
        <enums:W3CErrorOrWarningType> 
         ValidationWarning 
        </enums:W3CErrorOrWarningType> 
       </DataTrigger.Value> 
       <Setter TargetName="TypeIcon" 
         Property="Source" 
         Value="images/Warning.png"/> 
      </DataTrigger> 
     </DataTemplate.Triggers> 
    </DataTemplate> 

が、私はこのエラーを取得する:

Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'WpfApplication1.XhtmlTextBox.W3CValidator.W3CResponse.W3CErrorOrWarning' that is not included in the assembly.

My WpfApplication1プロジェクトにはユーザーコントロールが含まれていますXhtmlTextBox。そのユーザーコントロールがW3CErrorOrWarningType呼ば列挙が含まW3CErrorOrWarningと呼ばれるクラスが含まW3CResponseと呼ばれるクラスが含まW3CValidatorと呼ばれるクラスを含んでいます。

このタイプの名前空間をウィンドウのXAMLに入力するにはどうすればよいですか?

答えて

1

編集:私はそれが間違っだと思うが、初めてけど...

ネームスペースで列挙名を含めていますか?

は、私は次のようになります。W3CResponseはXAMLは、ネストされたクラスをサポートしていない、あなたはXAMLで直接ネストされた列挙型を使用できないタイプの場合は、上記のすべてを考慮し

xmlns:enums="clr-namespace:WpfApplication1.XhtmlTextBox.W3CValidator.W3CResponse 

は、名前空間とないタイプです。残念だ

Requirements for a Custom Class as a XAML Element

Your custom class must not be a nested class

+0

。 –

関連する問題