Dailycode.info

Short solution for short problems

ContentPresenter and tabindex

When you are using contentpresenters to show some custom controls, then you will see that there is no TabIndex property available. Instead use this:

KeyboardNavigation.TabNavigation="Local"

KeyboardNavigation.TabIndex=0

So your contentpresenter could look like this:

<ContentPresenter Content="{Binding Path=AudioTypeVM}"

                        ContentTemplate="{StaticResource AudioTypeListTemplate}"

                        HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="4" Margin="15,3,0,0"

                        KeyboardNavigation.TabNavigation="Local"

                        KeyboardNavigation.TabIndex="5">

 </ContentPresenter>

Then do not forget to arrange the tabindex of your custom control. In my case it's a dropdown list and a button:

<UserControl x:Class="MyMediaControl.Controls.CaseList"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

             mc:Ignorable="d"

             d:DesignHeight="24" d:DesignWidth="267">

    <DockPanel Height="24" LastChildFill="True" Width="251">

        <ComboBox DockPanel.Dock="Left"  HorizontalAlignment="Left" Name="cmbCases" VerticalAlignment="Top" MinWidth="200" ItemsSource="{Binding CaseListSource}" DisplayMemberPath="CaseID" SelectedItem="{Binding SelectedCase}" TabIndex="0"/>

        <Button DockPanel.Dock="Right" Content="New"  HorizontalAlignment="Right" Name="btnNew" VerticalAlignment="Top" MinWidth="50" Command="{Binding NewCaseCommand}" TabIndex="1"/>

    </DockPanel>

</UserControl>