[英]WPF Issue with Tab Navigation
我有控制模板,在这里:
<ControlTemplate x:Key="DialogWindowTemplate" TargetType="{x:Type w:DialogWindow}">
<Border d:DesignHeight="500" d:DesignWidth="700" CornerRadius="5" Background="{StaticResource ContrastWhiteBrush}"
BorderThickness="1" BorderBrush="{StaticResource ContentNormalBrush}">
<Grid>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right"
VerticalAlignment="Center" Margin="10,0,10,0">
<Button Content="{TemplateBinding ActionName}" Style="{StaticResource ButtonStyle}" KeyboardNavigation.TabIndex="1"
VerticalAlignment="Center" Margin="10,0,10,0" Padding="5,0,5,0" FontWeight="Bold" Height="30" Width="75"
Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActionCommand}"/>
<TextBlock Text="{x:Static loc:Controls.Dialog_Or}" Style="{StaticResource ContentNormalFontStyle}"
VerticalAlignment="Center" Margin="0"/>
<Button Style="{StaticResource CancelButtonStyle}" VerticalAlignment="Center" Margin="10,0,10,0" KeyboardNavigation.TabIndex="2"
Command="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CancelCommand}"/>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
这是.cs文件
public DialogWindow()
{
// load the template
ResourceDictionary rd = new ResourceDictionary();
rd.Source = new Uri(TEMPLATE_URI);
this.Resources.MergedDictionaries.Add(rd);
this.Template = this.Resources["DialogWindowTemplate"] as ControlTemplate;
this.WindowStyle = WindowStyle.None;
this.AllowsTransparency = true;
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseCommandHandler));
this.CommandBindings.Add(new CommandBinding(_escCommand, CloseCommandHandler));
}
我的问题是:我尝试了所有可能的选项,但“选项卡导航”不适用于这些按钮。 但是,当我按Ctrl + Tab时,它可以工作。 我也尝试过这个KeyBoard.ControlTabNavigation =“ None”。 但这不起作用。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.