The following template works fine if the user presses Enter, although I want the command to fire when the TextBox
loses focus as well. How can I do this?
If you don't use any MVVM framework you could use InvokeCommandAction
from System.Windows.Interactivity to execute command when event is fired
<TextBox ...>
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}, Path=DataContext.RenameCommand}"
CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
you'll need to add reference to System.Windows.Interactivity
and add namespace in your XAML:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"