views:

1596

answers:

1

I'm binding a collection of my W3CErrorOrWarning type objects to controls in a WPF Window.

One of its properties is named "Type". It is of type W3CErrorOrWarningType which is a simple Enum:

Enum W3CErrorOrWarningType
    ValidationError
    ValidationWarning
End Enum

I'm trying to use it in this way...

<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>

I get this error:

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 project contains a user control XhtmlTextBox. That user control contains a class called W3CValidator which contains a class called W3CResponse which contains a class called W3CErrorOrWarning which contains an enumeration called W3CErrorOrWarningType.

How do I enter the namespace for this type in my Window's XAML?

+1  A: 

EDIT: I think got it wrong, first time but ...

Are you including the enum name in the namespace ?

I should be:

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

considering all above are namespaces and not types, if W3CResponse is a type then you can't use the nested enum directly in XAML, XAML has no support for nested classes.

Requirements for a Custom Class as a XAML Element

Your custom class must not be a nested class

Pop Catalin
That's a bummer.
Zack Peterson