无法在TextBoxes之间获取Xaml选项卡

时间:2017-06-27 21:46:17

标签: c# wpf xaml

我正在尝试仅在选择用户名文本框和按摩文本框xaml之间选项卡。我的第一个问题是标签卡在输入用户名上,我的猜测是它有一个自定义控件用于下一个搜索建议。它还会查看视图中的每个按钮,我不希望它这样做。我试图在两个文本框中添加一个Tabindex,它没有任何效果。我在两个文本框中都离开了Tabidex,这样您就可以知道我想要在哪些文本框之间切换。

<UserControl x:Class="Clinical.Patient.Views.SendMessageDialogView"
             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"
             d:DataContext="{d:DesignInstance 
             Type=viewModels:SendMessageDialogViewModel}"
             mc:Ignorable="d"
             d:DesignWidth="320"
             xmlns:properties="clr-namespace:Clinical.Patient.Properties"
             xmlns:viewModels="clr-namespace:Clinical.Patient.ViewModels"
             xmlns:patient="clr-namespace:Clinical.Patient"
             xmlns:self="clr-namespace:System;assembly=mscorlib"
             xmlns:views="clr-namespace:Clinical.Patient.Views"
             d:DesignHeight="350"
             xmlns:termAutoComplete="clr-
             namespace:Clinical.Patient.Controls.TermAutoComplete"
             xmlns:controls="clr-namespace:Clinical.Patient.Controls"
             KeyboardNavigation.TabNavigation="Local">

    <UserControl.Resources>
        <viewModels:IsAtLeastGradeConverter x:Key="IsAtLeastGradeConverter"/>
        <viewModels:IsAtLeastAutoCloseGradeConverter x:Key="IsAtLeastAutoCloseGradeConverter"/>
    </UserControl.Resources>
    <Border Padding="8"
            MinWidth="320"

            ClipToBounds="False">
        <Border BorderThickness="1"
                BorderBrush="{DynamicResource FocusBorderBrush}"
                CornerRadius="2"
                Background="{DynamicResource FocusBackgroundBrush}">
            <Border.Effect>
                <DropShadowEffect Color="{DynamicResource SubtleDivideBorderColor}"
                                  Opacity="1"
                                  ShadowDepth="0"
                                  BlurRadius="10" />
            </Border.Effect>

            <StackPanel Orientation="Vertical"
                        Margin="10">

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center"
                           Text="{x:Static properties:Strings.SharingReportIs}"
                           Foreground="{DynamicResource CommonTextBrush}"
                           FontSize="13"
                           FontWeight="Bold"/>

                    <Border Grid.Column="1"
                        Width="180"
                        Margin="5 5 20 5"
                        HorizontalAlignment="Left"
                        Background="{DynamicResource FocusBackgroundBrush}"
                        BorderBrush="{DynamicResource FocusBorderBrush}"
                        BorderThickness=".5"
                        CornerRadius="8,8,8,8">
                        <DockPanel HorizontalAlignment="Center">
                            <views:ExamTypeIconView DockPanel.Dock="Left"
                                    Type="{Binding ExamType}"
                                    Foreground="{DynamicResource CommonTextBrush}"
                                    IconHeight="30"/>
                            <StackPanel DockPanel.Dock="Left"
                                Margin="3">
                                <TextBlock Text="{Binding Status}"
                                   Foreground="{DynamicResource CommonTextBrush}"
                                   FontSize="13"/>
                                <TextBlock Text="{Binding Accession}"
                                   Foreground="{DynamicResource CommonTextBrush}"
                                   FontSize="13"/>
                            </StackPanel>
                        </DockPanel>
                    </Border>
                </Grid>
                <DockPanel HorizontalAlignment="Left"
                           MinWidth="280"
                           Margin="0 5 0 0">
                    <Button
                        x:Name="To"
                        HorizontalAlignment="Right"
                        MinWidth="65"
                        Margin="0,4,4,4"
                        IsDefault="True"
                        Command="{Binding ToCommand}"
                        Content="to.." Width="65" />

                    <TextBox x:Name="SendTo"
                             Text="{Binding Recipient, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                             Style="{DynamicResource NavigationSearchTextBox}"
                             FontSize="{DynamicResource OneAndAQuarterFontSize}"
                             Padding="0 3 0 3"
                             VerticalAlignment="Center" 
                             Width="225"
                             TabIndex="0"/>

                    <termAutoComplete:TermAutoComplete AutoCompleteSource="{Binding AutoCompleteSource}"
                                                       Padding="0 0 0 0"
                                                       TextBox="{Binding ElementName=SendTo}"/>

                </DockPanel>

                <Grid Margin="0 5 0 0">
                    <TextBlock Text="{x:Static properties:Strings.SharingMessage}"
                                Foreground="{DynamicResource CommonTextBrush}"
                                FontSize="13"
                                FontWeight="Bold" />
                </Grid>
                <TextBox x:Name="PeerReviewComments"
                         Margin="0 5 0 0"
                         MinLines="5"
                         AcceptsReturn="True"
                         TextWrapping="Wrap"
                         Text="{Binding Message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         Width="295"
                         TabIndex="1"/>
                <DockPanel
                           MinWidth="280"
                           Margin="0,5,-5,0"
                           >
                    <Button
                    x:Name="Save"
                    HorizontalAlignment="Right"enter code here
                    MinWidth="65"
                    Margin="0,4,4,4"
                    IsDefault="True"
                    Command="{Binding SendCommand}"
                    Content="Send" Width="65"
                    DockPanel.Dock="Right"

                    />
                    <Button
                    x:Name="Cancle"
                    HorizontalAlignment="Right"
                    MinWidth="65"
                    Margin="0,4,4,4"
                    IsDefault="True"
                    Command="{Binding CancelCommand}"
                    Content="Cancel" Width="65"
                    DockPanel.Dock="Right"
                    />



                </DockPanel>

            </StackPanel>
        </Border>
    </Border>
</UserControl>

2 个答案:

答案 0 :(得分:1)

我相信你需要更换&#34; TabIndex&#34;使用&#34; KeyboardNavigation.TabIndex&#34;。

如果这不起作用,您还可以通过在XAML中的元素上设置KeyboardNavigation.IsTabStop来跳过标签序列中的元素。

KeyboardNavigation.IsTabStop="False"

Source

答案 1 :(得分:1)

对于标签&#34;卡住的控件&#34;添加:

KeyboardNavigation.TabNavigation="Continue"

要避免标签点击控件添加:

KeyboardNavigation.IsTabStop="False"