UWP: compilation error when using the x: DataType property on a DataTemplate

I am creating a new UWP Blank App project focused on the Anniversary Build Windows. Here's the markup for my only page (which is called MainPage.xaml by default):

<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <DataTemplate x:Key="MyDataTemplate" x:DataType="local:BindyThing"> </DataTemplate> </Grid.Resources> </Grid> 

The BindyThing class is declared as follows in the CS file:

 namespace App1 { public class BindyThing { } } 

As you can see from the markup above, I'm trying to create a DataTemplate to render BindyThing. However, when compiling, I get the following error:

The XAML Binary Format (XBF) generator reported syntax error '0x09C4' : Property Not Found

This error disappears when I comment on a DataTemplate declaration. Does anyone have an idea why I am getting this? All help was appreciated. Thanks!

+6
source share
2 answers

It looks like you cannot have an empty DataTemplate in your xaml. I was able to bring your example to work with below:

 <DataTemplate x:Key="MyDataTemplate" x:DataType="local:BindyThing"> <TextBlock></TextBlock> </DataTemplate> 
+7
source

(My commentary in response to Sergey turned out to be convenient for several people, so I am promoting it to make it more visible)

I ran into the same problem and my DataTemplate not empty. However, it was defined in App.xaml. Just moving it to where it referred, and removing the x:Key attribute made it work fine.

+2
source

All Articles