I have two lists with different ItemsSource but with SelectedItem bound to the same property – “Name“.
First i’m choosing the item “c” in the right list so the item “c” in the left list is selected as well.
Than I selected another item in the right list but the “c” in the left list is still selected.
I understand why it do that, but can I make it unselect the “c” in the right list ?

XAML:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ListView SelectedItem="{Binding Name}" ItemsSource="{Binding lstNames1}"/>
<ListView SelectedItem="{Binding Name}" ItemsSource="{Binding lstNames2}" Grid.Column="1"/>
</Grid>
Code behind:
public partial class selected : Window
{
public ObservableCollection<string> lstNames1 { get; set; }
public ObservableCollection<string> lstNames2 { get; set; }
public string Name { get; set; }
public selected()
{
Names1 = new ObservableCollection<string> {"a1", "b1", "c"};
Names2 = new ObservableCollection<string> { "a2", "b2", "c" };
InitializeComponent();
DataContext = this;
}
}
If you switch the
SelectedItembinding toSelectedValuethis will behave how you want, TheSelectedItemis not clearing because its not set tonullbecause the other list has set a value,SelectedValueacts a bit differntly as it has to find an item or it will clear theSelectedItemon the list.Hope that make sense 🙂