Search code examples
c#xamlwindows-phone-8datatemplateuwp

DataTemplate not able to resolve DataType prefix data


Left Image is the error and the right one is a Microsoft example

I'm trying to implement ListView in UWP using Window's sample code.

<ListView.GroupStyle>
            <GroupStyle >
                <GroupStyle.HeaderTemplate>
                    <DataTemplate x:DataType="data:GroupInfoList">
                        <TextBlock Text="{x:Bind Key}" 
                                   Style="{ThemeResource TitleTextBlockStyle}"/>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListView.GroupStyle>

The line -

DataTemplate x:DataType="data:GroupInfoList"

Is giving me error, shown in the left image, When creating models am I suppose to create them differently.It says

The namespace prefix "data" is not defined.

Is it a namespace that I need to include?


Solution

  • I have just had the same issue, this page was copied/pasted from the Universal ListView sample.

    The pasted page was full of bad characters, such as line feeds etc. I cleaned the page by removing lines and line feeds around the data template and all is fine.