开发者

Error in XAML: Type reference cannot find public type

开发者_StackOverflow中文版

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜