Custom DataType in DataTemplate breaks WPF designer

Posted by PRINCESS FLUFF on Stack Overflow See other posts from Stack Overflow or by PRINCESS FLUFF
Published on 2010-04-18T10:51:57Z Indexed on 2010/04/18 11:43 UTC
Read the original article Hit count: 359

Why does the DataTemplate line break the WPF designer in Visual Studio 2008?

The program compiles and runs properly. The DataTemplate is applied as it should. However the entire DataTemplate block of code is underlined in red, and when I simply "build" the program without running, I get the error "Type reference cannot find public type named 'Character'"

How come it can't find it in the designer yet the program applies the template properly?

<UserControl x:Class="WPF_Tests.Tests.TwoCollecViews.TwoViews"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:DetailsPane="clr-namespace:WPF_Tests.Tests.DetailsPane" 
    >
   <UserControl.Resources>

      <DataTemplate DataType="{x:Type DetailsPane:Character}">
         <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Path=Name}"></TextBlock>
         </StackPanel>
      </DataTemplate>

   </UserControl.Resources>

   <Grid>
      <ListBox ItemsSource="{Binding Path=Characters}"  />
   </Grid>
</UserControl>

EDIT: I am being told that this may be a bug in Visual Studio 2008, as it worked correctly in 2010. You can download the code here: http://www.mediafire.com/?z1myytvwm4n - The Test/TwoCollec xaml file's designer will break with this code.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about datatemplate