views:

454

answers:

1

In my WPF application, I have a TreeView control defined in my XAML. I've added a TreeView.Resources section that looks like this:

<TreeView.Resources>
    <HierarchicalDataTemplate DataType="{x:Type local:FileGroup}" ItemsSource="{Binding protXMLFiles}">
        <TextBlock Text="{Binding Path=groupName}"/>
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate DataType="{x:Type local:protXMLFile}" ItemsSource="{Binding}">
        <TextBlock Text="{Binding Path=filename}"/>
     </HierarchicalDataTemplate>
</TreeView.Resources>

Above, I defined the "local" namespace with a line at the top:

<Window x:Class="FileGrouper.SPWindow" ... xmlns:local="clr-namespace:FileGrouper"...>

When I try to load my XAML in the Visual Studio Designer, I get a warning at the top of the designer that goes: "The document contains errors that must be fixed before the designer can be updated. Click here to open the Error List"; the related error message in the Error List goes: "Type reference cannot find public type named 'FileGroup'". All the errors in the Error List clear after I compile, and the application runs without a problem.

Nevertheless, I still cannot use the XAML designer unless I remove the < TreeView.Resources> block. What's going on here, and how can I fix it?

+1  A: 

Do you need to specify the assembly name in the xmlns declaration? The IDE normally puts that in for me.

Jonathan Allen
Yep. I tried just saying {x:Type FileGroup} and it wouldn't compile. It only compiles when I declare the "local" namespace and write {x:Type local:FileGroup}.
Vivek