• <i id='iK6Xm'><tr id='iK6Xm'><dt id='iK6Xm'><q id='iK6Xm'><span id='iK6Xm'><b id='iK6Xm'><form id='iK6Xm'><ins id='iK6Xm'></ins><ul id='iK6Xm'></ul><sub id='iK6Xm'></sub></form><legend id='iK6Xm'></legend><bdo id='iK6Xm'><pre id='iK6Xm'><center id='iK6Xm'></center></pre></bdo></b><th id='iK6Xm'></th></span></q></dt></tr></i><div id='iK6Xm'><tfoot id='iK6Xm'></tfoot><dl id='iK6Xm'><fieldset id='iK6Xm'></fieldset></dl></div>
      • <bdo id='iK6Xm'></bdo><ul id='iK6Xm'></ul>

      <tfoot id='iK6Xm'></tfoot>

      <small id='iK6Xm'></small><noframes id='iK6Xm'>

        <legend id='iK6Xm'><style id='iK6Xm'><dir id='iK6Xm'><q id='iK6Xm'></q></dir></style></legend>

        MoveFocus 从一个列表框到另一个

        时间:2023-10-08

        <tfoot id='4rCv6'></tfoot>

      1. <small id='4rCv6'></small><noframes id='4rCv6'>

            <bdo id='4rCv6'></bdo><ul id='4rCv6'></ul>
            • <legend id='4rCv6'><style id='4rCv6'><dir id='4rCv6'><q id='4rCv6'></q></dir></style></legend>

                  <tbody id='4rCv6'></tbody>

                  <i id='4rCv6'><tr id='4rCv6'><dt id='4rCv6'><q id='4rCv6'><span id='4rCv6'><b id='4rCv6'><form id='4rCv6'><ins id='4rCv6'></ins><ul id='4rCv6'></ul><sub id='4rCv6'></sub></form><legend id='4rCv6'></legend><bdo id='4rCv6'><pre id='4rCv6'><center id='4rCv6'></center></pre></bdo></b><th id='4rCv6'></th></span></q></dt></tr></i><div id='4rCv6'><tfoot id='4rCv6'></tfoot><dl id='4rCv6'><fieldset id='4rCv6'></fieldset></dl></div>
                • 本文介绍了MoveFocus 从一个列表框到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有类似 Windows 8 开始菜单的输出.

                  I have the Output something like Windows 8 Start Menu.

                  这是我的输出的屏幕截图:

                  Here is screen-shot of my Output:

                  通过从 这个问题.

                  XAML 用于实现以下输出:

                  XAML for achieving the below output:

                  <ItemsControl ItemsSource="{Binding MenuCategories}" >
                  
                      <ItemsControl.ItemsPanel>
                          <ItemsPanelTemplate>
                              <StackPanel IsItemsHost="True" Orientation="Horizontal" />
                          </ItemsPanelTemplate>
                      </ItemsControl.ItemsPanel>
                  
                      <ItemsControl.ItemTemplate>
                          <DataTemplate>
                              <Grid >
                                  <Grid.RowDefinitions>
                                      <RowDefinition Height="Auto" />
                                      <RowDefinition Height="*" />
                                  </Grid.RowDefinitions>
                  
                                  <TextBlock Text="{Binding Title}" FontSize="30" />
                  
                                  <ListBox Grid.Row="1" x:Name="lst" ItemsSource="{Binding Design_Master_TileItem}" BorderThickness="0"
                                           SelectedItem="{Binding DataContext.SelectedTile, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}}"
                                           helpers:SingleSelectionGroup.SelectionGroup="Group">
                  
                                      <ListBox.ItemsPanel>
                                          <ItemsPanelTemplate>
                                              <WrapPanel IsItemsHost="True" Orientation="Vertical" MaxHeight="{Binding ElementName=lst, Path=ActualHeight}"/>
                                          </ItemsPanelTemplate>
                                      </ListBox.ItemsPanel>
                  
                                      <ListBox.Resources>
                                          <Style TargetType="{x:Type ListBoxItem}">
                                              <Setter Property="Width" Value="250" />
                                              <Setter Property="Height" Value="125" />
                                              <Setter Property="Margin" Value="2.5" />
                                              <Setter Property="Padding" Value="2.5" />
                                              <Setter Property="Background" Value="{Binding Background, Converter={StaticResource stringToBrushConverter}}" />
                                              <Setter Property="Foreground" Value="White" />
                                              <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                              <Style.Triggers>
                                                  <Trigger Property="IsSelected" Value="True">
                                                      <Setter Property="Foreground" Value="{Binding Background, Converter ={StaticResource stringToBrushConverter}}" />
                                                  </Trigger>
                                                  <Trigger Property="IsKeyboardFocusWithin" Value="True">
                                                      <Setter Property="IsSelected" Value="True"></Setter>
                                                  </Trigger>
                                              </Style.Triggers>
                                          </Style>
                                      </ListBox.Resources>
                  
                                      <ListBox.ItemTemplate>
                                          <DataTemplate>
                                              <StackPanel Orientation="Horizontal" Height="125" Width="250">
                                                  <Path Data="{Binding ImageData}"  VerticalAlignment="Center" 
                                                        Stretch="Uniform" Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"
                                                        Width="68" Height="68" Margin="10" RenderTransformOrigin="0.5,0.5">
                                                      <Path.RenderTransform>
                                                          <TransformGroup>
                                                              <TransformGroup.Children>
                                                                  <RotateTransform Angle="0" />
                                                                  <ScaleTransform ScaleX="1" ScaleY="1" />
                                                              </TransformGroup.Children>
                                                          </TransformGroup>
                                                      </Path.RenderTransform>
                                                  </Path>
                                                  <TextBlock Text="{Binding Title, Converter={StaticResource spaceToNewLineConverter}}" VerticalAlignment="Top" 
                                                             Margin="40,10,10,10" FontSize="24" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/>
                                              </StackPanel>
                                          </DataTemplate>
                                      </ListBox.ItemTemplate>
                  
                                  </ListBox>
                              </Grid>
                          </DataTemplate>
                      </ItemsControl.ItemTemplate>
                  </ItemsControl>
                  

                  所以,从上面的代码你可能已经明白 Group 和 Ledger 是 listbox1 的两项.其他四个是listbox2的项目.

                  So, from the above code you might have understood that Group and Ledger are two items of listbox1. and other four are the items of listbox2.

                  要求:

                  假设,ListboxA 中的 ItemA1 被选中.

                  Suppose, ItemA1 is selected in listboxA.

                  案例 1:新行为

                  如果 ListBoxA 在 Item1 的右侧没有任何项目,那么当我按右箭头键时,焦点应移动到 listboxB 的 ItemB1.同样,如果 listboxA 的 ItemA2 被选中,那么焦点应该移到 ListBoxB 的 ItemB2.

                  If ListBoxA does not have any items on the right side of Item1, then when I press right arrow key the focus should move to the ItemB1 of listboxB. Likewise if ItemA2 of listboxA is selected then the focus should move to the ItemB2 of ListBoxB.

                  案例 2:默认行为

                  如果 ListBoxA 在 ItemA1 的右侧有一些项目,则应通过按右箭头键选择该项目.我默认有这种行为,但我不想打扰它.我的意思是在实现 Case1 时,我不想放弃默认行为.

                  If ListBoxA has some items on the right hand side of ItemA1, then that item should be selected by pressing right arrow key. I have this behavior by default but I don't want to disturb it. I mean while implementing Case1 I don't want to loose the default behavior.

                  推荐答案

                  您当前的 xaml 代码在这里工作正常.请参考此链接以获取 KeyBoardNavigation 键盘导航

                  Your Current xaml code working fine here.. Please refer this link for KeyBoardNavigation Keyboardnavigation

                  您只需将 KeyboardNavigation.DirectionalNavigation="Continue" KeyboardNavigation.TabNavigation="Continue" 添加到列表框,它就会按预期工作.

                  You need to add only KeyboardNavigation.DirectionalNavigation="Continue" KeyboardNavigation.TabNavigation="Continue" to listbox and it works as expected.

                     <ItemsControl KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" Focusable="False"  >
                          ...
                  
                          <ListBox Grid.Row="1" x:Name="lst" KeyboardNavigation.DirectionalNavigation="Continue" KeyboardNavigation.TabNavigation="Continue"   BorderThickness="0"/>
                      ..
                  
                     </ItemsControl>
                  

                  这篇关于MoveFocus 从一个列表框到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 C# 更改 WPF 列表框 SelectedItem 文本颜色和突出显示/背景颜色 下一篇:如何禁用列表框中的选定项目

                  相关文章

                • <i id='8cpeK'><tr id='8cpeK'><dt id='8cpeK'><q id='8cpeK'><span id='8cpeK'><b id='8cpeK'><form id='8cpeK'><ins id='8cpeK'></ins><ul id='8cpeK'></ul><sub id='8cpeK'></sub></form><legend id='8cpeK'></legend><bdo id='8cpeK'><pre id='8cpeK'><center id='8cpeK'></center></pre></bdo></b><th id='8cpeK'></th></span></q></dt></tr></i><div id='8cpeK'><tfoot id='8cpeK'></tfoot><dl id='8cpeK'><fieldset id='8cpeK'></fieldset></dl></div>
                • <legend id='8cpeK'><style id='8cpeK'><dir id='8cpeK'><q id='8cpeK'></q></dir></style></legend>

                  <small id='8cpeK'></small><noframes id='8cpeK'>

                    1. <tfoot id='8cpeK'></tfoot>
                        <bdo id='8cpeK'></bdo><ul id='8cpeK'></ul>