C# XamlReader抛出未声明的前缀错误
我对资源的定义如下:C# XamlReader抛出未声明的前缀错误,c#,silverlight,C#,Silverlight,我对资源的定义如下: <DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid x:Name="grdArticle" Height="190" Width="190" toolkit:TiltEffect.IsTiltEnable
<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="grdArticle" Height="190" Width="190" toolkit:TiltEffect.IsTiltEnabled="True">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="samplePhoto.jpg" Grid.Row="0" Stretch="UniformToFill"/>
<Grid Grid.Row="0" Height="55" VerticalAlignment="Bottom">
<Rectangle Grid.Row="0" Fill="{StaticResource PhoneAccentBrush}"/>
<TextBlock Grid.Row="0" Text="{Binding Title}" Canvas.ZIndex="2" VerticalAlignment="Bottom" TextWrapping="Wrap" Margin="5,5,5,5" Height="50" FontStyle="Normal">
<TextBlock.Foreground>
<SolidColorBrush Color="#BFFFFFFF"/>
</TextBlock.Foreground>
</TextBlock>
</Grid>
</Grid>
</DataTemplate>
我得到了XamlParseException,在第2行104号位置说“未声明的前缀”。
我从互联网上尝试了许多xmlns标记,但似乎没有任何效果。有什么帮助吗?未声明的是
toolkit
前缀。您需要添加
xmlns:toolkit="..."
到
或外部
元素。将..
替换为要绑定到应用程序中其他位置的xmlns:toolkit
顺便问一下,这样将资源的内容解析为XAML有什么原因吗?通常,我会将
DataTemplate
放在Resources
资源字典的某个地方,或者放在Application.Resources
中。这样,编译器将检查它是否是有效的XAML。非常感谢。这件事浪费了我4个小时。
xmlns:toolkit="..."