C# 无法将EventToCommand添加到TriggerActionCollection
我正在使用MVVM Light处理一个WPF项目,并尝试使用C# 无法将EventToCommand添加到TriggerActionCollection,c#,.net,wpf,mvvm,mvvm-light,C#,.net,Wpf,Mvvm,Mvvm Light,我正在使用MVVM Light处理一个WPF项目,并尝试使用EventToCommand,但我收到一条错误消息,上面说: 无法将“EventToCommand”类型的值添加到“TriggerActionCollection”类型的集合或词典中。” 我正在使用.NET Framework 4.7.2和NuGet库Microsoft.Xaml.Behaviors.Wpf 我见过很多地方谈论http://schemas.microsoft.com/expression/2010/interactivi
EventToCommand
,但我收到一条错误消息,上面说:
无法将“EventToCommand”类型的值添加到“TriggerActionCollection”类型的集合或词典中。”
我正在使用.NET Framework 4.7.2和NuGet库Microsoft.Xaml.Behaviors.Wpf
我见过很多地方谈论http://schemas.microsoft.com/expression/2010/interactivity
,
但据我所知,这是现在不赞成的,而且http://schemas.microsoft.com/xaml/behaviors应改用
在mvvmlight.net的变更日志中,我发现:
事件命令-
BL0004.005,程序集“GalaSoft.MvvmLight.Extras.WPF4”中的类型“EventToCommand”是使用旧版本的Blend SDK生成的,在Windows Presentation Framework 4项目中不受支持
我尝试过更改项目目标框架版本,但似乎没有什么不同
任何帮助都将不胜感激
<UserControl x:Class="DialogueTree.View.DialogueControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:DialogueTree.View"
xmlns:command="http://www.galasoft.ch/mvvmlight"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="200"
MinHeight="200" MinWidth="200">
来自MvvmLight的
EventToCommand
操作基于旧版Blend SDK程序集
- XML名称空间
http://schemas.microsoft.com/expression/2010/interactivity
- CLR名称空间
System.Windows.Interactivity
EventToCommand
,因为XAML行为包已经包含一个执行相同操作的命令:InvokeCommandAction
。但是属性名称可能不同
<b:EventTrigger EventName="LostFocus">
<b:InvokeCommandAction Command="{Binding Source={StaticResource Locator}, Path=DialogueControlVM.EndEditHeadline}"
CommandParameter="{Binding}"/>
</b:EventTrigger>
<b:EventTrigger EventName="LostFocus">
<b:InvokeCommandAction Command="{Binding Source={StaticResource Locator}, Path=DialogueControlVM.EndEditHeadline}"
CommandParameter="{Binding}"/>
</b:EventTrigger>