1

I have an AvalonEdit on my window. When I press key combination Ctrl+Up or Ctrl+Down when inside editor, AvalonEdit loses focus, which is transferred to a different control, as below:

AvalonEdit lost focus

This sometimes happen as well when using Ctrl+Left or Ctrl+Right combinations.

My current XAML definition looks like following:

<ae:TextEditor x:Name="teEditor"
            Grid.Row="0"
            Grid.Column="0"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            BorderThickness="0"
            FontFamily="Consolas"      
            FontSize="10pt"
            TabIndex="0"             
            WordWrap="{Binding ElementName=Root, Path=Handler.WordWrap}"
            ShowLineNumbers="{Binding ElementName=Root, Path=Handler.LineNumbers}"
            ContextMenu="{StaticResource EditorContextMenu}"
            GotFocus="HandleEditorGotFocus" 
            KeyboardNavigation.ControlTabNavigation="None"
            KeyboardNavigation.AcceptsReturn="True"
            KeyboardNavigation.DirectionalNavigation="None"
            KeyboardNavigation.TabNavigation="None"/>

How can I prevent that?

2
  • Can you cut your XAML down to the bare minimum needed to reproduce?
    – Jim Foye
    Commented Mar 4, 2020 at 21:27
  • I use AvalonEdit 5.0.3. I cannot reproduce that behavior.
    – Ketobomb
    Commented Mar 5, 2020 at 9:06

1 Answer 1

1

It turns out, that problem appears, when you place AvalonEdit inside TabControl. In such case you have to disable keyboard navigation on the TabControl by adding:

KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.