• <small id='KNgCh'></small><noframes id='KNgCh'>

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

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

      <tfoot id='KNgCh'></tfoot>

      1. WPF 两个列表框之间的单选

        时间:2023-10-07

          <tbody id='Z8T06'></tbody>

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

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

                1. <legend id='Z8T06'><style id='Z8T06'><dir id='Z8T06'><q id='Z8T06'></q></dir></style></legend>
                2. 本文介绍了WPF 两个列表框之间的单选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我遇到以下问题:我有两个 ListBox,有两个不同的 ItemSource,但它们都有相同的 binding对于 SelectedItem,因为我试图在这两个列表之间执行单个选择.

                  I'm having the following problem: I have two ListBox, with two different ItemSource, but both of them have the same binding for the SelectedItem, because I was trying to perform a single selection between these two lists.

                  这是一张更能说明问题的图片:

                  Here's an image that better shows the problem:

                  我想做什么?每次我从第一个列表(红色)中选择一个项目时,它应该取消选择第二个列表(黑色)中的 SelectedItem,反之亦然.这就是为什么我对它们都使用相同的 binding 的原因.我真的不知道这是否是更好的方法,但它应该像那样工作.

                  What would I like to do? Every time I select one item from the first list (in red), it should deselect the SelectedItem from the second list (in black), and vice versa. That's why I'm using the same binding for both of them. I really don't know if it's the better way to do it, but it should work like that.

                  你能帮帮我吗?

                  推荐答案

                  我要做的是首先将 null 传递给属性并通知更改,然后将实际值传递给属性并通知更改视图.像这样:

                  What I had to do was at first pass null to the property and notify the changing, and then I passed the real value to the property and notified the changing to the view. Like that:

                  protected Bar selectedItem;
                  public Bar SelectedItem{
                      get
                      {
                          return selectedItem;
                      }
                      set
                      {
                          selectedItem = null;
                          NotifyPropertyChanged("SelectedItem");
                  
                          selectedItem = value;
                          NotifyPropertyChanged("SelectedItem");
                      }
                  

                  我从 this question 中得到了这个答案和示例.

                  I got this answer and example from this question.

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

                  上一篇:C# ListBox ObservableCollection&lt;T&gt; 下一篇:将 ListBox 放入 ScrollViewer:鼠标滚轮不起作用

                  相关文章

                    <bdo id='MNO6P'></bdo><ul id='MNO6P'></ul>

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

                    <tfoot id='MNO6P'></tfoot>