长列表选择器项中的XAML数据模板突然无效(WP8)

4

几天前我出现了这个错误,看起来它已经消失了。但现在它却不会消失。我还遇到了一个Adcontrol错误:在使用此控件之前需要设置ApplicationId和AdUnitId在另一个应用程序中,Adcontrol的设置方式完全相同,所以我不知道问题在哪里,也找不到任何相关信息。

编辑: 如果我删除带有双括号 }} 的代码部分,无效错误就会消失。我也将Adcontrol完全删除以隔离错误。然而,当我运行应用程序时,仍然会出现以下错误:

**A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll

    Additional information: Could not load file or assembly 'Microsoft.Phone.Controls.Toolkit.resources, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.**

我已经卸载并重新安装了WPToolkit。我在另一个应用程序中使用类似的代码和WPToolkit,但它不会出现这个错误。我还能做什么?
无效的XAML:
<DataTemplate x:Key="SoundTileDataTemplate">
    <StackPanel>
        <Grid Margin="0,5,6,0" Height="100" Width="140"
              toolkit:TiltEffect.IsTiltEnabled="True">
            <Border BorderBrush="#FF49A609" BorderThickness="1" CornerRadius="3,3,3,3" Background="{StaticResource PhoneAccentBrush}" Opacity=".6"/>
            <TextBlock Text="{Binding Title}" FontSize="19" TextWrapping="Wrap" Width="140"  FontFamily="/BBSM;component/Fonts/123Sketch.ttf#123Sketch" TextAlignment="Center" />
            <Image Source="/Assets/tiles/TRXHSBRGIcon.png" Width="30" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,6,6" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToIconVisibilityConverter}}" />
            <ProgressBar Height="12" VerticalAlignment="Bottom" Padding="0" Margin="0" Foreground="{StaticResource PhoneForegroundBrush}" Value="{Binding DownloadProgress}" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToProgressBarVisibilityConverter}}"/>
        </Grid>
    </StackPanel>
</DataTemplate>

<DataTemplate x:Key="ExtrasTileDataTemplate">
    <StackPanel>
        <toolkit:ContextMenuService.ContextMenu>
            <toolkit:ContextMenu IsZoomEnabled="False" >
                <toolkit:MenuItem Header="Save as Ringtone"  Command="{Binding SaveSoundAsRingtone}" CommandParameter="{Binding FilePath}" />
            </toolkit:ContextMenu>
        </toolkit:ContextMenuService.ContextMenu>
        <Grid Margin="0,5,6,0" Height="100" Width="140"
              toolkit:TiltEffect.IsTiltEnabled="True">
            <Border BorderBrush="#FF49A609" BorderThickness="1" CornerRadius="3,3,3,3" Background="{StaticResource PhoneAccentBrush}" Opacity=".6"/>
            <TextBlock Text="{Binding Title}" FontSize="19" TextWrapping="Wrap" Width="140"  FontFamily="/BBSM;component/Fonts/123Sketch.ttf#123Sketch" TextAlignment="Center" />
            <Image Source="/Assets/tiles/TRXHSBRGIcon.png" Width="30" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,6,6" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToIconVisibilityConverter}}" />
            <ProgressBar Height="12" VerticalAlignment="Bottom" Padding="0" Margin="0" Foreground="{StaticResource PhoneForegroundBrush}" Value="{Binding DownloadProgress}" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToProgressBarVisibilityConverter}}"/>
        </Grid>
    </StackPanel>
</DataTemplate>

Adcontrol:

<UI:AdControl ApplicationId="*********" AdUnitId="******" Width="480" IsAutoRefreshEnabled="True" Grid.Row="1" Height="80"/>

当我运行项目时,出现了以下问题。我每次都点击继续,然后应用程序会运行,但是枢轴标题全部混乱,但是应用程序似乎是功能完好的。
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.DLL

Additional information: You can not use PubCenter IDs for testing in the emulator. If you want to test with these IDs, please deploy your application to a device. Otherwise please change your ApplicationId to "test_client" and AdUnitId to one of the supported ad types as outlined in the documentation.

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll

Additional information: Could not load file or assembly 'Microsoft.Phone.Controls.Toolkit.resources, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

什么是错误?或者ApplicationID是唯一的问题吗? - Chris W.
@ChrisW。另一个错误显示为无效的XAML。当我点击它们时,两个错误都指向上面的DataTemplates。非常奇怪。 - user3568429
@ChrisW。我运行项目时添加了一些错误。在模拟器中,我从未收到过关于使用真实广告 ID 的错误。广告只是不会显示出来,这没关系。我将尝试重新安装 WPToolkit。 - user3568429
1
几天前我遇到了与我的ListBox Datatemplate相同的问题。这篇帖子帮助了我。试一下吧。让我知道 http://social.msdn.microsoft.com/Forums/silverlight/en-US/fb20c0e2-e16b-4ff6-8ada-40791bb4e416/invalid-xaml?forum=silverlightcontrols#63ab033e-292b-4bd3-a0ee-92bccbd6af59 - Kumar
你确定正确引用了 Advertising 组件吗?它好像在抱怨这个问题?请检查你的引用/清理/重建。 - anthonyhumphreys
显示剩余3条评论
1个回答

0
如果您正在使用Windows Phone Toolkit,则必须包含此内容。
 xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:cc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

在你的*.xaml页面中


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接