【问题标题】:WPF Ribbon steals TABWPF Ribbon 抢断 TAB
【发布时间】:2015-02-11 21:09:07
【问题描述】:

我有一个带有功能区和几个控件的简单 WPF 应用程序。不幸的是,当按 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" />

【问题讨论】:

    标签: wpf focus ribbon


    【解决方案1】:

    好的。让我自己回答。出于我的目的,不使用 TAB 作为功能区是可以的。对于功能区,我可以使用 KeyTip(s),所以基本上我刚刚将 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>
    

    【讨论】:

      【解决方案2】:

      KeyboardNavigation.TabNavigation="Continue" 使用 System.Windows.Controls.Ribbon.dll 为我做这件事

      【讨论】:

        猜你喜欢
        • 2020-11-04
        • 2010-12-02
        • 1970-01-01
        • 1970-01-01
        • 2014-01-22
        • 2011-03-08
        • 2012-09-16
        • 1970-01-01
        • 2016-01-11
        相关资源
        最近更新 更多