我定义了一个资源如下:
<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>
当我尝试使用以下方法解析它时:
DataTemplate dtTmplt = XamlReader.Load(PhoneApp5.Resource1.Datatemplate_lst) as DataTemplate;
我收到 XamlParseException,在第 2 行第 104 位说“未声明的前缀”。我尝试了许多来自互联网的 xmlns 标签,但似乎没有任何效果。有什么帮助吗?