Simplified: In my view I've got a xaml page containing a button and some kind of TextBox. The button is bound to a DelegateCommand in the ViewModel, the editbox is bound to some property in the ViewModel.
View:
<Button Command="{Binding MyCommand}"/>
<TextBox Text="{Binding MyString}"/>
ViewModel:
public DelegateCommand MyCommand { get; set; }
public String MyString { get; set; }
Now when the user enters something into the box and clicks on the button, the button does not receive a focus change event. So it will not update it's content to the property. So the property MyString does not reflect the content of the TextBox on clicking the button. So whatever processing MyCommand is doing, it is working with old data and not the current input.
Now if this really was just a TextBox I'd add UpdateSourceTrigger=PropertyChanged to the binding and I'd be good. But in this case the edit control is a bit more complex and needs to do some validation to the content. So I need some kind of "lost focus" signal when pressing the button by mouse.
My problem is: in MVVM the code behind for the button does not have any access to the view, so it can't make it lose the focus.
Is there any way in xaml (e.g. in the view) to make the button get the keyboard focus when it is clicked by mouse? That would be the easiest way for my custom control to get a "lost focus" message.