我正在尝试在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>
除了... 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
这导致设计师破裂,所以即使代码有效,设计师也不会。有什么想法吗?
我的包括......
xmlns:interact="using:Microsoft.Xaml.Interactivity"
xmlns:interactcore="using:Microsoft.Xaml.Interactions.Core"
为了澄清,我通过“添加引用...”对话框包含了行为SDK。
答案 0 :(得分:2)
对我有用的答案是Grace Feng在问题中所做的评论,并得到Nick的证实。
那时使用Windows 10 Universal应用程序使用Microsoft.Xaml.Behaviors.Uwp.Managed nuget包并删除Behaviors SDK(XAML)包