0

I am trying to use LostFocus event as Command in DataGridTextColumn and can't find an example on how to use it in WPF. Can anyone help me use it as I am new to WPF.

Thank you.

My xaml looks like:

   `

    The c# code:
          public partial class Myogg : UserControl    {
          MyLogg _viewModel;
         public MyLogg()
          {
              InitializeComponent();
              _viewModel = new MyLoggUCViewModel();
              DataContext = _viewModel;
          }
        }`
user2388887
  • 67
  • 1
  • 3
  • 8
  • Does this answer your question? [Textbox Binding to both LostFocus and Property Update](https://stackoverflow.com/questions/15488033/textbox-binding-to-both-lostfocus-and-property-update) – BurnsBA Jan 09 '20 at 01:43

1 Answers1

2

you can use interaction triggers to do this ..

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>

Muds
  • 4,006
  • 5
  • 31
  • 53
  • Is still doesn't work. I created a propriety LostFocusCommand which it is never fired. – user2388887 Mar 09 '15 at 14:30
  • public ICommand LostFocusCommand { get { return _saveRowCommand ?? (_lostFocusCommand = new LostFocusCommand()); } } and the class LostFocusCommand looks like: public class SaveRowCommand:ICommand { public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { return true; } public void Execute(object parameter) { MessageBox.Show("LostFocus") } } – user2388887 Mar 09 '15 at 15:47