title: Synchronizing IsSelected and SelectedItem in a ListView
body: <p>I have some images (positions) in a WPF control. Each image correlates to an item in a <code>ListView</code> beneath that control. When the user clicks on a position, I want the corresponding <code>ListViewItem</code> to be selected (and therefore highlighted) in the <code>ListView</code>. Similarly, when the user clicks on a <code>ListViewItem</code>, I want the corresponding position to be selected.</p>
  
  <p>I can accomplish one behavior or the other, but I can't seem to get both working together.</p>
  
  <p>I have a <code>Style</code> that sets the <code>IsSelected</code> property to `true' when a position is selected:</p>
  
  <pre><code>&lt;Style x:Key="PositionItem" TargetType="ListViewItem"&gt;
      &lt;Setter Property="IsSelected" Value="False" /&gt;
      &lt;Style.Triggers&gt;
          &lt;DataTrigger Value="True"&gt;
              &lt;DataTrigger.Binding&gt;
                  &lt;MultiBinding Converter="{StaticResource IsCurrentPositionConverter}"&gt;
                      &lt;Binding RelativeSource="{RelativeSource Self}" Path="DataContext" /&gt;
                      &lt;Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" Path="DataContext.CurrentBackplane.CurrentCard.CurrentPosition" /&gt;
                  &lt;/MultiBinding&gt;
              &lt;/DataTrigger.Binding&gt;
              &lt;Setter Property="IsSelected" Value="True" /&gt;
          &lt;/DataTrigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>In my <code>ListView</code>, I set a handler for <code>SelectionChanged</code>:</p>
  
  <pre><code>private void Positions_SelectionChanged(object sender, SelectionChangedEventArgs e) {
      var listView = sender as ListView;
      if (listView == null) return;
      var currentPos = listView.SelectedItem as IGraphicPositionViewModel;
      if (currentPos == null) return;
      if (currentPos != _ViewModel.CurrentBackplane.CurrentCard.CurrentPosition)
          _ViewModel.CurrentBackplane.CurrentCard.CurrentPosition = currentPos;
  }
  </code></pre>
  
  <p><strong>The problem is</strong> that the <code>IsSelected</code> property of the <code>ListViewItem</code>doesn't seem to correlate well with the <code>SelectedItem</code> property of the <code>ListView</code>. </p>
  
  <p>Is there some other property or event I can use to synchronize these properties?</p>