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:
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.
Could you help me?
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:I got this answer and example from this question.
Try using
SelectedValue
instead, this will sop the behaviour you are seeingIt seems that
SelectedItem
does not deselect is the selected item is not found in the list, ButSelectedValue
does seem to deselect it, not sure whyYou can see the diffence in this sample app:
xaml:
code: