为什么 System.Windows.Interactivity 不想工作? [英] Why System.Windows.Interactivity doesn't want to work?
本文介绍了为什么 System.Windows.Interactivity 不想工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚将这一行添加到我的 XAML 文件中:
I just added this line to my XAML file:
xmlns:interactivity="clr-namespace:System.Windows.Interactivity"
首先我收到一个未定义的 CLR 命名空间错误,但在构建之后它被修复了.现在,当我尝试在 mt XAML 文件中添加一个交互标签时,我在这个命名空间上得到了一个完整的错误.
First I get an Undefined CLR namespace error but after a build it was fixed. Now when I try to add an interactivity tag in mt XAML file I get an complete error on this namespace.
这是我的代码示例
<Window x:Class="ColorTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity"
xmlns:ignore="http://www.ignore.com"
mc:Ignorable="d ignore"
Height="576"
Width="720"
Title="MVVM Light Application"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<Grid x:Name="LayoutRoot" Background="#FF44494D">
<Rectangle x:Name="Color01" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="100" Margin="10,29,0,0" Stroke="Black" VerticalAlignment="Top" Width="100">
<!--<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDown">
<interactivity:InvokeCommandAction Command="{Binding MyCommand}"/>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>-->
</Rectangle>
</Grid>
为了帮助这里是我的项目文件的一部分,我的参考
To help here is a part of my project file with my references
<Reference Include="GalaSoft.MvvmLight.Extras.WPF45">
<HintPath>packages\MvvmLightLibs.4.2.30.0\lib\net45\GalaSoft.MvvmLight.Extras.WPF45.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.WPF45">
<HintPath>packages\MvvmLightLibs.4.2.30.0\lib\net45\GalaSoft.MvvmLight.WPF45.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\MvvmLightLibs.4.2.30.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
最后,我想让您知道我安装了 Blend,但从未打开或使用过它.
To finish I would like to let you know I installed Blend but never opened it or used it.
推荐答案
这是用于 XAML 中交互的正确命名空间:
This is the correct namespace for interactivity within XAML:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
这篇关于为什么 System.Windows.Interactivity 不想工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文