Nic*_*ick 5 c# xaml windows-10-universal
我正在尝试使用 XAML 中的 Interaction.Behaviors 将事件绑定到我的控制器,如下所示,
<GridView x:Name="mygrid" >
<interact:Interaction.Behaviors>
<interactcore:EventTriggerBehavior EventName="SelectionChanged">
<interactcore:InvokeCommandAction
Command="{Binding Controller.Test}"
CommandParameter="{Binding ElementName=mygrid, Path=SelectedItem}"/>
</interactcore:EventTriggerBehavior>
</interact:Interaction.Behaviors>
</GridView>
Run Code Online (Sandbox Code Playgroud)
这工作完美,除了... Visual Studio 2015 显示以下错误,
Severity Code Description Project File Line Suppression State
Error The name "EventTriggerBehavior" does not exist in the namespace "using:Microsoft.Xaml.Interactions.Core". MVC C:\Prototype\MVC\MVC\MainPage.xaml 19
Error The name "InvokeCommandAction" does not exist in the namespace "using:Microsoft.Xaml.Interactions.Core". MVC C:\Prototype\MVC\MVC\MainPage.xaml 20
Error The name "Interaction" does not exist in the namespace "using:Microsoft.Xaml.Interactivity". MVC C:\Prototype\MVC\MVC\MainPage.xaml 18
Run Code Online (Sandbox Code Playgroud)
这导致设计器崩溃,因此即使代码有效,设计器也没有。有任何想法吗?
我的包括...
xmlns:interact="using:Microsoft.Xaml.Interactivity"
xmlns:interactcore="using:Microsoft.Xaml.Interactions.Core"
Run Code Online (Sandbox Code Playgroud)
为了澄清起见,我通过“添加引用...”对话框包含了行为 SDK。
对我有用的答案是 Grace Feng 在问题中所做的评论,并得到了 Nick 的确认。
那就是在执行 Windows 10 通用应用程序时使用 Microsoft.Xaml.Behaviors.Uwp.Managed nuget 包并删除 Behaviors SDK (XAML) 包