title: WPF listbox binding selected only updates items in view
body: <p>I've been running into a strange issue with a listbox within a UserControl with WPF and MVVM. The listbox has its items bound via a ViewModel and an <code>ObservableCollection&lt;T&gt;</code>, the style property <code>IsSelected</code> is bound to a property <code>Selected</code> inside the individual items.</p>
  <pre><code>[...]
  &lt;ListBox ItemsSource=&quot;{Binding Path=SQLObjects}&quot; FontFamily=&quot;Consolas&quot; Margin=&quot;5,0,5,5&quot; DisplayMemberPath=&quot;Name&quot; SelectionMode=&quot;Extended&quot; SelectedItem=&quot;{Binding Path=SelectedSQLObject}&quot;&gt;
      &lt;ListBox.Resources&gt;
          &lt;Style TargetType=&quot;{x:Type ListBoxItem}&quot; BasedOn=&quot;{StaticResource MetroListBoxItem}&quot;&gt;
              &lt;Setter Property=&quot;IsSelected&quot; Value=&quot;{Binding Selected, Mode=TwoWay}&quot; /&gt;
          &lt;/Style&gt;
      &lt;/ListBox.Resources&gt;
  &lt;/ListBox&gt;
  [...]
  </code></pre>
  <p>When a user selects a single or multiple items (with ctrl or shift) the properties are updated as expected. But selecting all items with <code>ctrl + a</code> only updates the property <code>Selected</code> of the items visible inside the scroll area of the listbox.</p>
  <p><a href="https://i.stack.imgur.com/6pKRt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6pKRt.png" alt="GUI" /></a></p>
  <p>in the screenshot all items are selected with <code>ctrl + a</code> but only the items currently visible have their property updated. When scrolling down in the listbox without changing the selection, all items are updated as they come into view.</p>
  <p>Could this be caused by <a href="https://www.nuget.org/packages/MahApps.Metro/1.6.5" rel="nofollow noreferrer">MahApps.Metro</a>?</p>
  <p>The ViewModel is bound to the UserControls Datacontext inside the xaml in the main window.</p>
  <pre><code>[...]
  &lt;TabItem Header=&quot;Trigger&quot;&gt;
      &lt;userControls:ObjectControl&gt;
          &lt;userControls:ObjectControl.DataContext&gt;
              &lt;viewmodel:TriggerObjectViewModel DialogCoordinator=&quot;{x:Static local:MainWindow.Coordinator}&quot; /&gt;
          &lt;/userControls:ObjectControl.DataContext&gt;
      &lt;/userControls:ObjectControl&gt;
  &lt;/TabItem&gt;
  [...]
  </code></pre>
  <p>All other TabItems use the same usercontrol and have the same issue.</p>
  <p>I would like to not use a workaround (e.g. scrolling trought the whole list when the user selects items outside of the current view), is there any kind of property I could set for WPF to update all items inside a collection, regardless if they are visible or not?</p>