Search code examples
c#wpfxaml

Type reference cannot find public type named


I am getting error like "Type reference cannot find public type named 'Sign'" in xaml. how can i resolve it. the Sign class is in the same assembly.

<DataTemplate DataType="{x:Type local:Sign}">
    <Expander Padding="4"
              IsExpanded="{Binding RelativeSource={
                    RelativeSource Mode=FindAncestor, AncestorType={
                       x:Type ListBoxItem}}, Path=IsSelected}">
        <Expander.Header>
            <TextBlock Text="{Binding Name}" ... />
        </Expander.Header>
        <DockPanel LastChildFill="True">
            <Border DockPanel.Dock="Left" CornerRadius="16" BorderBrush="WhiteSmoke" Background="AliceBlue" BorderThickness="5" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Image Source="{Binding Icon}" Width="90" Height="90" Stretch="Fill" />
            </Border>
            ...
        </DockPanel>                
    </Expander>


Solution

  • If the type resides in the same assembly as the XAML you are modifying, omit the assembly segment of the clr-namespace when you import the namespace.

    DO

    xmlns:local="clr-namespace:NamespaceContainingSignClass"
    

    DO NOT

    xmlns:local="clr-namespace:NamespaceContainingSignClass;assembly=AssemblyContainingSignClassAndXAML"