我有控制模板,在这里:
<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));
}
我的问题是:我尝试了所有可能的选项但Tab导航不适用于那些按钮。但是当我按下Ctrl + Tab然后它就可以了。我试过这个KeyBoard.ControlTabNavigation =“无”。但它不起作用。
由于