I've updated jen's code to resolve the issue as follows:
public override List<DelegateCommandWrapper> ProvideCommandsForKey(KeyEventArgs args)
{
List<DelegateCommandWrapper> actionsToExecute = base.ProvideCommandsForKey(args);
if (args.Key == Key.Enter)
{
if (args.OriginalSource is TextBox && (args.OriginalSource as TextBox).AcceptsReturn)
{
TextBox textBox = args.OriginalSource as TextBox;
actionsToExecute.Clear();
StringBuilder stringBuilder = new StringBuilder(textBox.Text);
stringBuilder.Insert(textBox.SelectionStart, Environment.NewLine); // add new line
textBox.Text = stringBuilder.ToString();
textBox.SelectionStart += 3; // move cursor to new line
textBox.Focus();
}
else
{
actionsToExecute.Clear();
actionsToExecute.Add(new DataFormDelegateCommandWrapper(RadDataFormCommands.CommitEdit, this.DataForm));
}
}
return actionsToExecute;
}
public override List<DelegateCommandWrapper> ProvideCommandsForKey(KeyEventArgs args)
{
List<DelegateCommandWrapper> actionsToExecute = base.ProvideCommandsForKey(args);
if (args.Key == Key.Enter)
{
if (args.OriginalSource is TextBox && (args.OriginalSource as TextBox).AcceptsReturn)
{
TextBox textBox = args.OriginalSource as TextBox;
actionsToExecute.Clear();
StringBuilder stringBuilder = new StringBuilder(textBox.Text);
stringBuilder.Insert(textBox.SelectionStart, Environment.NewLine); // add new line
textBox.Text = stringBuilder.ToString();
textBox.SelectionStart += 3; // move cursor to new line
textBox.Focus();
}
else
{
actionsToExecute.Clear();
actionsToExecute.Add(new DataFormDelegateCommandWrapper(RadDataFormCommands.CommitEdit, this.DataForm));
}
}
return actionsToExecute;
}