DataTemplate中针对longlistselector项突然发生的XAML无效(WP8)

时间:2014-08-18 14:40:53

标签: xaml windows-phone-8 datatemplate

几天前发生了这个错误,它似乎消失了。现在它不会消失。我也收到了一个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它并没有给我这个错误。我还能做什么?

INVALID 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>

广告控制:

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

当我运行项目时,我得到以下内容。我继续每一个,应用程序运行,但Pivot标题都搞砸了,但应用程序似乎功能。

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.

1 个答案:

答案 0 :(得分:0)

如果您正在使用Windows Phone工具包 你必须包括

 xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:cc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

在* .xaml页面