Spook
Spook

Reputation: 25927

Wpf, AvalonEdit and keyboard navigation problem

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?

Upvotes: 1

Views: 359

Answers (1)

Spook
Spook

Reputation: 25927

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"

Upvotes: 1

Related Questions