WPF项目中,从Nuget搜索并下载System.Windows.Interactivity.dll,安装到项目中,并在XAML界面引入。

<UserControl

    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">

....

</UserControl>

在目标UI控件上添加一个鼠标右键点击弹起事件。

    <!-- 鼠标右键事件 -->
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseRightButtonDown">
<!-- 激发ViewModel中自定义的ICommand命令,同时演示如何传参 --> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.MouseRightButtonDownCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type Button}}}"/> </i:EventTrigger> </i:Interaction.Triggers>

 

现在的问题是:在Visual Studio中书写EventTrigger的EventName时,没有智能提示的,如何查看这里还能写哪些可选的事件?

可选的事件有以下这些:


 

重要的参考:

https://stackoverflow.com/questions/22060381/is-there-a-list-available-for-eventtrigger-eventnames

 

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2021-11-17
  • 2022-01-10
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-10-25
  • 2021-11-03
  • 2021-06-15
  • 2021-12-29
相关资源
相似解决方案