title: Property already registered by 'ListView'
body: <p>I have this code:</p>
  
  <pre><code>using System.Collections;
  using System.Windows;
  using System.Windows.Controls;
  
  public static class SelectedItems
  {
      private static readonly DependencyProperty SelectedItemsBehaviorProperty = DependencyProperty.RegisterAttached(
          "SelectedItemsBehavior",
          typeof(SelectedItemsBehavior),
          typeof(ListView),
          null);
  
      public static readonly DependencyProperty ItemsProperty = DependencyProperty.RegisterAttached(
          "Items",
          typeof(IList),
          typeof(SelectedItems),
          new PropertyMetadata(null, ItemsPropertyChanged));
  
      public static void SetItems(ListView listView, IList list)
      {
          listView.SetValue(ItemsProperty, list);
      }
  
      public static IList GetItems(ListView listView)
      {
          return listView.GetValue(ItemsProperty) as IList;
      }
  
      private static void ItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
      {
          var target = d as ListView;
          if (target != null)
          {
              CreateBehavior(target, e.NewValue as IList);
          }
      }
  
      private static void CreateBehavior(ListView target, IList list)
      {
          var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
          if (behavior == null)
          {
              behavior = new SelectedItemsBehavior(target, list);
              target.SetValue(SelectedItemsBehaviorProperty, behavior);
          }
      }
  }
  
  public class SelectedItemsBehavior
  {
      private readonly ListView _listView;
      private readonly IList _boundList;
  
      public SelectedItemsBehavior(ListView listView, IList boundList)
      {
          _boundList = boundList;
          _listView = listView;
          _listView.SelectionChanged += OnSelectionChanged;
      }
  
      private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          _boundList.Clear();
  
          foreach (var item in _listView.SelectedItems)
          {
              _boundList.Add(item);
          }
      }
  }
  </code></pre>
  
  <p>XAML:</p>
  
  <pre><code>    &lt;ListView SelectionMode="Extended" ItemsSource="{Binding Computers}" Views:SelectedItems.Items="{Binding SelectedComputers}" BorderBrush="Transparent" Height="100" VerticalAlignment="Top"&gt;
          &lt;ListView.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal"  HorizontalAlignment="Left" VerticalAlignment="Top"  /&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ListView.ItemsPanel&gt;
          &lt;ListView.Background&gt;
              &lt;SolidColorBrush Color="Black" /&gt;
          &lt;/ListView.Background&gt;
      &lt;/ListView&gt;
  </code></pre>
  
  <p>I've got an error of </p>
  
  <blockquote>
    <p>'SelectedItemsBehaviour' property was already registered by
    'Listview'.</p>
  </blockquote>
  
  <p>I've used this code in two places on two separate <code>ListViews</code> and both give this error.</p>
  
  <p>Why am I getting it, everything is static. I am using the MVVM design pattern.</p>
  
  <p>Thanks,</p>