2012-03-30 19 views
0

下のXAMLでは、最初のツールバー(以下のツールバー1)はフォーカスを失いませんし、KeyboardNavigation.TabNavigation = "一度"設定されます。私がそれを動作させる唯一の方法は、ツールバーのすべての要素をスタックパネルやグリッド(以下のツールバー2)などの別のコンテナに配置することです。ただし、オーバーフロー機能が適切に機能しません。幅を小さくすると、個々のアイテムの代わりに内部のコンテナ全体がオーバーフローします。KeyboardNavigation.TabNavigation =ツールバー上の「一度」がフォーカスを失うことはありません。すべての要素が別のコンテナに含まれていない場合

私の必要条件は、必要に応じてオーバーフローする個々のアイテムのオーバーフロー機能を失うことなく、最初の要素の後にツールバーからタブアウトすることです(残りのアイテムのユーザーは矢印キーを使用します)。

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="600" Width="525"> 
<Grid> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="50" /> 
    <RowDefinition Height="50" /> 
    <RowDefinition Height="100" /> 
    <RowDefinition Height="50" /> 
    <RowDefinition Height="100" /> 
    <RowDefinition Height="50" /> 
    </Grid.RowDefinitions> 
    <TextBox Grid.Row="0" Text="First" Width="600"></TextBox> 
    <TextBox Grid.Row="1" Text="Second" Width="600"></TextBox> 

    <DockPanel LastChildFill="True" Grid.Row="2" Background="Red" > 
    <ToolBar x:Name="Toolbar1" DockPanel.Dock="Top" 
     VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="40" BandIndex="1" Band="1" 
      KeyboardNavigation.TabNavigation="Once" > 
     <Button Background="Red" Content="1" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
     <Button Background="Red" Content="2" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
     <Button Background="Red" Content="3" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
     <Button Background="Red" Content="4" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
     <Button Background="Red" Content="5" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
    </ToolBar> 
    <TextBox DockPanel.Dock="Bottom" Text="I'm first Rich Text Box, My toolbar is not in a inner container." Height="50" Width="600"></TextBox> 
    </DockPanel>  

    <TextBox Grid.Row="3" Text="Third" Width="600"></TextBox> 

    <DockPanel LastChildFill="True" Grid.Row="4" Background="Green"> 
    <ToolBar x:Name="Toolbar2" DockPanel.Dock="Top" 
     VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="40" BandIndex="1" Band="1" 
      KeyboardNavigation.TabNavigation="Once" > 
     <StackPanel Orientation="Horizontal" KeyboardNavigation.TabNavigation="Once" > 
     <Button Background="Green" Content="1" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" /> 
     <Button Background="Green" Content="2" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/> 
     <Button Background="Green" Content="3" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/> 
     <Button Background="Green" Content="4" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/> 
     <Button Background="Green" Content="5" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/> 
     </StackPanel> 
    </ToolBar> 
    <TextBox DockPanel.Dock="Bottom" Text="I'm second Rich Text Box, My toolbar is in a inner container." Height="50" Width="600"></TextBox> 
    </DockPanel> 

    <TextBox Grid.Row="5" Text="Fourth" Width="600"></TextBox> 

</Grid> 

答えて

0

私が正しい取得するとして、あなたはあなたのToolBar1ためFocusManager.IsFocusScope添付プロパティをオフにする必要があり、私がいないのですか?

関連する問題