Why can't I select a null value in a ComboBox?

后端 未结 10 2094
花落未央
花落未央 2020-12-08 06:11

In WPF, it seems to be impossible to select (with the mouse) a \"null\" value from a ComboBox. Edit To clarify, this is .NET 3.5 SP1.

Here\'s some c

10条回答
  •  余生分开走
    2020-12-08 07:13

    Just a guess, but I think it sounds reasonable.

    Assume combobox is using "ListCollectionView" (lcv as its instance) as its item collection, which it should be. If you are a programmer, what you gonna do?

    I will respons to both Keyboard and Mouse.

    Once I get Keyboard input, I use

    lcv.MoveCurrentToNext();
    

    or

    lcv.MoveCurrentToPrevious();
    

    So, sure keyboard works well.

    Then I am working on respons Mouse inputs. And it comes the problem.

    1. I want to listen 'MouseClick' event of my item. But probably, my Item doesn't generated, it is just a placeholder. So when user click on this placeholder, I get nothing.

    2. If I get the event successfully, what's next. I will invoke

      lcv.MoveCurrentTo(selectedItem);

    the "selectedItem" which would be null is not an acceptable parameter here I think.

    Anyway, it's just guessing. I don't have time to debug into it though I am able to. I have a bunch of defects to fix. Good Luck. :)

提交回复
热议问题