Compact 7 Applying Style to Control used as DataTemplate causes Invalid XAML Error
-
Wednesday, May 30, 2012 8:51 AM
I wrote several controls that are used for DataTemplates and they are all working fine. I then wrote a Style for a Button which I named "ButtonStyle" and applied it to the Control:
<Grid x:Name="LayoutRoot"> <StackPanel Orientation="Horizontal"> <TextBlock Width="20" Height="20" Text=" "></TextBlock> <Button Style="{StaticResource ButtonStyle}" x:Name="TestButton" Height="31" Tag="{Binding Path=Id}" Content="{Binding Path=LogicalName}" Width="100" Click="TestButton_Click" /> <TextBlock Width="20" Height="20" Text=" "></TextBlock> <CheckBox Width="15" Height="20" x:Name="ItemStatus" Grid.Row="0" Content="{Binding Path=LogicalName}" VerticalAlignment="Center" IsChecked="{Binding Path=IOStatus, Mode=TwoWay}" ClickMode="Release" IsHitTestVisible="False" IsTabStop="False" /> </StackPanel> </Grid>The Control is used in App.xaml as a DataTemplate:
<DataTemplate x:Key="IODataTemplate"> <local:IOItemControl /> </DataTemplate>
After I applied the style I recompiled it. It did this successfully but afterwards the code in App.xaml was highlighted and gave an "Invalid XAML" error. I can run the application and it works fine but it's annoying to have this error because with it the Pages refuse to show the content using these DataTemplates complaining that there are errors.
I then took the content of the control and put it directly into the DataTemplate. This would show no error at all (which I think it would have if there had been any problems with the Style itself). Unfortunately I need the code to be in the control so I can write eventhandlers for individual items, like the CheckBox. Anybody any idea why this error shows up and if there is any way to stop it?
CLight

