• <small id='2Xvi3'></small><noframes id='2Xvi3'>

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

        ListBox Shift-Click Multi-Select Anchor 未正确设置

        ListBox Shift-Click Multi-Select Anchor is not being set properly(ListBox Shift-Click Multi-Select Anchor 未正确设置)
            <tbody id='HexLx'></tbody>
            <tfoot id='HexLx'></tfoot>
          • <small id='HexLx'></small><noframes id='HexLx'>

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

            1. <i id='HexLx'><tr id='HexLx'><dt id='HexLx'><q id='HexLx'><span id='HexLx'><b id='HexLx'><form id='HexLx'><ins id='HexLx'></ins><ul id='HexLx'></ul><sub id='HexLx'></sub></form><legend id='HexLx'></legend><bdo id='HexLx'><pre id='HexLx'><center id='HexLx'></center></pre></bdo></b><th id='HexLx'></th></span></q></dt></tr></i><div id='HexLx'><tfoot id='HexLx'></tfoot><dl id='HexLx'><fieldset id='HexLx'></fieldset></dl></div>
                <bdo id='HexLx'></bdo><ul id='HexLx'></ul>
                  本文介绍了ListBox Shift-Click Multi-Select Anchor 未正确设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I’m at my wit’s end trying to figure this out. I'm experienced in WPF, but I've never seen anything like this.

                  I have a ListBox that contains selectable ListBoxItems. Items in the list can be selected by mouse click or by using the up/down arrows. I’m using SelectionMode.Extended, so my list supports multiple selections.

                  The problem: Clicking on an item in the list, then Shift-Clicking on another item selects the correct range of items like you would expect. Unfortunately, using the up/down arrows does not work properly – instead, the range that’s selected always seems to be based off of the last CLICKED item, not the item that was selected with the arrow keys.

                  For example:

                  [Item 1] <- Click this item
                  [Item 2] <- Use the down arrow to select this item
                  [Item 3] <- Shift-Click this item
                  

                  You would expect items 2 and 3 to be selected, instead, all of the items (1, 2, and 3) are selected.

                  All of the ListBox properties have the correct values (i.e. using the arrow keys updates the SelectedItems property), my only problem seems to be with how the ListBox is handling Shift-Click selection internally. To the best of my knowledge, I believe this has to do with the ListBox’s "multi-select anchor" getting set by mouse-click but not with the arrow keys.

                  Has anyone encountered and solved this before? Is there a way to set the "multi-select anchor" manually? Thanks for your help!

                  Chris

                  解决方案

                  I've figured out the resolution to this:

                  In order to solve this, you must set Focus to the item after changing the SelectedIndex:

                  if (SelectedIndex > 0) {
                       SelectedIndex--;
                       ListBoxItem item = ItemContainerGenerator.ContainerFromIndex(SelectedIndex) as ListBoxItem;
                       item.Focus();
                  }
                  

                  This is how you move the selection down in the list. However, you need to set focus to the item for the shift-click selection to recognize the item as the anchor.

                  这篇关于ListBox Shift-Click Multi-Select Anchor 未正确设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                    <legend id='9RGjF'><style id='9RGjF'><dir id='9RGjF'><q id='9RGjF'></q></dir></style></legend>
                          <bdo id='9RGjF'></bdo><ul id='9RGjF'></ul>
                          <tfoot id='9RGjF'></tfoot>
                          <i id='9RGjF'><tr id='9RGjF'><dt id='9RGjF'><q id='9RGjF'><span id='9RGjF'><b id='9RGjF'><form id='9RGjF'><ins id='9RGjF'></ins><ul id='9RGjF'></ul><sub id='9RGjF'></sub></form><legend id='9RGjF'></legend><bdo id='9RGjF'><pre id='9RGjF'><center id='9RGjF'></center></pre></bdo></b><th id='9RGjF'></th></span></q></dt></tr></i><div id='9RGjF'><tfoot id='9RGjF'></tfoot><dl id='9RGjF'><fieldset id='9RGjF'></fieldset></dl></div>

                              <tbody id='9RGjF'></tbody>

                            <small id='9RGjF'></small><noframes id='9RGjF'>