如何在 WPF 中将 LostFocus 用作命令

How to use LostFocus as a Command in WPF

我正在尝试将 LostFocus 事件用作 DataGridTextColumn 中的命令,但找不到有关如何在 WPF 中使用它的示例。 任何人都可以帮助我使用它,因为我是 WPF 的新手。

谢谢。

我的 xaml 看起来像:

   `

    The c# code:
          public partial class Myogg : UserControl    {
          MyLogg _viewModel;
         public MyLogg()
          {
              InitializeComponent();
              _viewModel = new MyLoggUCViewModel();
              DataContext = _viewModel;
          }
        }`

您可以使用交互触发器来执行此操作..

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

<i:Interaction.Triggers>
    <i:EventTrigger EventName="LostFocus">
        <i:InvokeCommandAction Command="{Binding Path=LostFocusCommand}"/>
    </i:EventTrigger>
</i:Interaction.Triggers>