当我打开一个 XAML 项目时,错误列表将报告我打开的每个页面上所有行为的问题。示例如下:
The name "EventTriggerBehavior" does not exist in the namespace "using:Microsoft.Xaml.Interactions.Core"
The name "Interaction" does not exist in the namespace "using:Microsoft.Xaml.Interactivity"
但我确实有并确认了对 BehaviorsXamlSDKManaged 的引用,并且该项目可以正常编译和运行。
如果我打开 Blend,通过右键单击解决方案资源管理器或在 Windows 资源管理器中打开它 - Blend 将报告相同的错误,当我转到 Assets 列表时 - 行为将为空白
如果我创建一个 Javascript 版本,所有行为都会被发现。
我在这上面花了几天时间后被难住了,任何帮助将不胜感激。
---- 编辑:我尝试重新安装 VS2013
最佳答案
我通过为我的 Phone 和 Windows 项目添加对 XAML 行为的引用解决了这个错误: 添加引用 -> Windows 8.1 -> 扩展 -> 行为 SDK (XAML)。 Windows 8.1 或 Windows Phone 8.1 Core 中不包含 Microsoft.Xaml.Interactivity.Interaction。
<Page
x:Class="App1.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
mc:Ignorable="d">
<Page.Resources>
<local:ItemClickedConverter x:Key="ItemClickedConverter" />
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<GridView>
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ItemClick">
<core:InvokeCommandAction
Command="{Binding GoToContentCommand}"
InputConverter="{StaticResource ItemClickedConverter}">
</core:InvokeCommandAction>
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
</GridView>
</Grid>
关于c# - XAML 项目的 Blend 和 VS2013 中缺少行为,但存在于 Javascript 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21914377/