WPF Ribbon steals选项卡

WPF Ribbon steals选项卡,wpf,focus,ribbon,Wpf,Focus,Ribbon,我有一个简单的WPF应用程序,带有Ribbon和一些控件。不幸的是,当按TAB键改变焦点时,Ribbon只在自身内部管理循环,其他控件没有机会 这是XAML: <Window x:Class="WpfApplication4.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006

我有一个简单的WPF应用程序,带有Ribbon和一些控件。不幸的是,当按TAB键改变焦点时,Ribbon只在自身内部管理循环,其他控件没有机会

这是XAML:

<Window x:Class="WpfApplication4.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
    Title="MainWindow" Height="350" Width="525" >
<Grid>
<Grid.RowDefinitions>
  <RowDefinition Height="136" />
  <RowDefinition Height="175*" />
</Grid.RowDefinitions>
<my:Ribbon HorizontalAlignment="Stretch" Name="ribbon1" VerticalAlignment="Top">
  <my:RibbonTab Header="Ribbon">
    <my:RibbonGroup>
      <my:RibbonComboBox Label="ComboBox" Name="ribbonComboBox1">
        <my:RibbonGallery MaxColumnCount="1">
          <my:RibbonGalleryCategory>
            <my:RibbonGalleryItem Content="An item" />
          </my:RibbonGalleryCategory>
        </my:RibbonGallery>
      </my:RibbonComboBox>
    </my:RibbonGroup>
  </my:RibbonTab>
</my:Ribbon>
<TextBox TabIndex="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="12,19,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
<TextBox TabIndex="2" Height="23" HorizontalAlignment="Left" Margin="12,48,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Grid.Row="1" />


好的。让我自己回答。出于我的目的,不使用功能区选项卡是可以的。对于Ribbon,我可以使用KeyTip,所以基本上我只是在Ribbon定义中添加了Focusable=“False”KeyboardNavigation.TabNavigation=“None”。因此,整个代码可以如下所示:

<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
Title="MainWindow" Height="350" Width="525" >
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="136" />
      <RowDefinition Height="175*" />
    </Grid.RowDefinitions>
    <my:Ribbon Focusable="False" KeyboardNavigation.TabNavigation="None" HorizontalAlignment="Stretch" Name="ribbon1" VerticalAlignment="Top">
      <my:RibbonTab Header="Ribbon" KeyTip="R">
        <my:RibbonGroup>
          <my:RibbonComboBox KeyTip="C" Label="ComboBox" Name="ribbonComboBox1">
            <my:RibbonGallery MaxColumnCount="1">
              <my:RibbonGalleryCategory>
                <my:RibbonGalleryItem Content="An item" />
              </my:RibbonGalleryCategory>
            </my:RibbonGallery>
          </my:RibbonComboBox>
        </my:RibbonGroup>
      </my:RibbonTab>
    </my:Ribbon>
    <TextBox TabIndex="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="12,19,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
    <TextBox TabIndex="2" Height="23" HorizontalAlignment="Left" Margin="12,48,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Grid.Row="1" />
  </Grid>
</Window>

KeyboardNavigation.TabNavigation=“Continue”使用System.Windows.Controls.Ribbon.dll为我执行此操作