When pressing Shift+Up(Down) should create a selection to the start(end) of the document when the caret position is on the first(last) line. Currently, in this case, a selection is not created.
Such behavior can be achieved using the following approach:
private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is MoveCaretCommand && System.Windows.Input.Keyboard.Modifiers == ModifierKeys.Shift)
{
var command = e.Command as MoveCaretCommand;
MoveCaretDirections direction = (MoveCaretDirections)e.CommandParameter;
if (direction == MoveCaretDirections.Up)
{
var positionOnFirstLine = new DocumentPosition(this.radRichTextBox.Document);
positionOnFirstLine.MoveToFirstPositionInDocument();
if (this.radRichTextBox.Document.CaretPosition.Location.Y - positionOnFirstLine.Location.Y < 1)
{
this.radRichTextBox.Document.CaretPosition.MoveToPosition(positionOnFirstLine);
e.Cancel = true;
}
}
else if (direction == MoveCaretDirections.Down)
{
var positionOnLastLine = new DocumentPosition(this.radRichTextBox.Document);
positionOnLastLine.MoveToLastPositionInDocument();
if (positionOnLastLine.Location.Y - this.radRichTextBox.Document.CaretPosition.Location.Y < 1)
{
this.radRichTextBox.Document.CaretPosition.MoveToPosition(positionOnLastLine);
e.Cancel = true;
}
}
}
}