c# - XAML 项目的 Blend 和 VS2013 中缺少行为,但存在于 Javascript 项目中

标签 c# visual-studio xaml windows-store-apps blend

当我打开一个 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 的​​引用,并且该项目可以正常编译和运行。

enter image description here

如果我打开 Blend,通过右键单击解决方案资源管理器或在 Windows 资源管理器中打开它 - Blend 将报告相同的错误,当我转到 Assets 列表时 - 行为将为空白

Blank Asset List

如果我创建一个 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/

相关文章:

c# - 什么时候应该使用私有(private)变量,什么时候应该使用属性。支持字段应该在同一个类中使用吗?

c# - Distinct 子句导致类型错误

c# - 域对象和服务类对象应该放在哪里?

c++ - istream_iterator 需要左值 istringstream 吗?

c - Visual Studio 似乎将 header 编译为 .c 文件

javascript - Visual Studio for Windows 8.1 应用程序中的 CSS 范围

c# - 滚动 WPF TabItems(不是整个 TabControl)

c# - 无法将 lambda 表达式转换为类型 'string',因为它不是委托(delegate)类型

wpf - 如何在 App.xaml 中定义带有图标作为模板的菜单项

c# - 通过 MouseBinding 将鼠标事件与 ViewModel 连接