我有以下可视化树,我正在尝试通过 EventToCommand 发送命令。视觉效果如下:
<Border Background="Gray" Grid.Row="0" Margin="2" VerticalAlignment="Bottom">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<cmd:EventToCommand
Command="{Binding ShowVideosCmd}"
PassEventArgsToCommand="True"
CommandParameter="{Binding Videos}">
</cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
</Border>
单击命令附加到的边框时,出现以下弹出错误:
“在 GalaSoft.MvvmLight.WPF4.dll 中发生了“System.InvalidCastException”类型的未处理异常
附加信息:无法将“System.Windows.Input.MouseButtonEventArgs”类型的对象转换为“System.Windows.DependencyObject”类型。"
然后在 viemModel 中创建我的命令,如下所示:
ShowVideosCmd = new RelayCommand<DependencyObject>(
(dpObj) =>
{
messenger.Default.Send<string>("ShowVideos");
},
(dpObj) => true
);
我做错什么了 ?