我正在尝试将谷歌分析集成到我的 silverlight 4 浏览器应用程序中。当我在我的 XAML 中添加我的 Google Analytics 代码时,如下所示:
<i:Interaction.Behaviors>
<ga:GoogleAnalytics WebPropertyId="xxxxxxxxxxxxx"/>
</i:Interaction.Behaviors>
我收到一条错误消息,即
“向‘System.Windows.Interactivity.BehaviorCollection’类型的集合添加值引发异常。”
我在网上找不到太多关于这个的帮助,很少有人指出我的用户控制代码是:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
目前我正在为此使用 VS 2010 和 Blend 4。
感谢您阅读本文,如果您能在这个问题上帮助我,那就太好了。
编辑:
如前所述,我将数据放在这里:
在我的 App.xaml
<Application
x:Class="SilverlightApp.slate.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mwa="clr-namespace:Microsoft.WebAnalytics;assembly=Microsoft.WebAnalytics"
xmlns:ga="clr-namespace:Google.WebAnalytics;assembly=Google.WebAnalytics">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Assets/Styles.xaml"/>
<ResourceDictionary Source="CustomControls.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<mwa:WebAnalyticsService>
<mwa:WebAnalyticsService.Services>
<ga:GoogleAnalytics WebPropertyId="XXXXXXXXXXXXX" />
</mwa:WebAnalyticsService.Services>
</mwa:WebAnalyticsService>
</Application.ApplicationLifetimeObjects>
</Application>
在 Grid 下的 Main Page.XAML 中:
<Button x:Name="btn_library_Icon" Margin="86,2,64,6" Style="{StaticResource menu_librarybuttonstyle}" FontFamily="/SilverlightApp.slate;component/Fonts/Fonts.zip#Segoe UI" FontSize="9.333" Click="btn_library_Icon_Click">
<i:Interaction.Triggers>
<i:EventTrigger SourceName="btn_library_Icon" EventName="Click">
<mwab:TrackAction Category="Library Accessed"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Image x:Name="image" Source="Assets/icon_menu_library.png" Stretch="Fill" Width="23" Height="23"/>
</Button>
当我运行它时,它给了我一个错误: “向'System.Windows.Interactivity.TriggerCollection'类型的集合添加值引发了异常。”
我在这里想念什么吗?