In you XAML, include the following code in your Window tag:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
Next, inside you DataGrid element, add the following trigger:
<DataGrid ...>
<i:Interaction.Triggers>
<i:EventTrigger EventName="LoadingRow">
<cmd:EventToCommand Command="{Binding LoadRowHandler}"
PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGrid>
Next, in you View Model, add a command for handling the event :
public RelayCommand<DataGridRowEventArgs> LoadRowHandler{ get; private set; }
Inside constructor, initialize the command:
LoadRowHandler = new RelayCommand<DataGridRowEventArgs>(LoadingRowHandlerMethod);
Next, create a method where you want to put the logic:
private void LoadingRowHandlerMethod(DataGridRowEventArgs e)
{
//....
//....
}
That's all. Now whenever a new row is added to your DataGrid, the LoadingRowHandlerMethod will get executed.
Hope it helps.