我想谷歌分析整合在我的Silverlight 4出浏览器应用程序。当我在XAML像加我的谷歌Analytics(分析)的代码如下:
使用谷歌Analytics(分析)在Silverlight 4
<i:Interaction.Behaviors>
<ga:GoogleAnalytics WebPropertyId="xxxxxxxxxxxxx"/>
</i:Interaction.Behaviors>
我得到一个错误,这是 “增加价值型‘System.Windows.Interactivity.BehaviorCollection’的集合抛出例外。”
的xmlns:I =“HTTP://模式
我无法找到太多的关于这个网帮助,很少在这是我的用户控件的代码中指出。 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>
在主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’的集合引发了异常。”
我失去了一些东西?
如在邮件中提到我已加入它作为以下<应用 MWA:WebAnalyticsService> 但它示出了作为附加属性 '服务' 未在类型 'WebAnalyticsService' 发现错误。我正在使用最新版本1.4.10 –
感谢您的信息。我在App.xaml文件中添加了信息。现在我试图在Mainpage.xaml中添加Trigger事件,并且出现以下错误:“将值添加到类型'System.Windows.Interactivity.TriggerCollection'的集合中引发了一个异常。” 我已经包含的代码如下: \t \t \t \t \t \t \t \t i:EventTrigger> \t –
如果您编辑原始p ost包含这些代码示例。阅读这篇文章的人更容易阅读和更容易遵循。此外,它看起来像你在EventTrigger中缺少EventName。我猜它应该是“加载”。 –