title: Binding a ListView selected item to a user control
body: <p>I have a Page which contains a ListView of users :</p>
  
  <pre><code>&lt;ListView ItemsSource="{Binding UserList}"
            SelectedItem="{Binding SelectedUser}"&gt;
      &lt;GridView&gt;
          &lt;GridViewColumn DisplayMemberBinding="{Binding Id}" /&gt;
          &lt;GridViewColumn DisplayMemberBinding="{Binding Name}"/&gt;
      &lt;/GridVie&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>I have also a user control which will display all the data of the selected user from that ListView. So I binded the <code>SelectedUser</code> to a dependency property <code>CurrentUser</code> of <code>UserUc</code></p>
  
  <pre><code>&lt;userControls:UserUc CurrentUser="{Binding SelectedUser}" /&gt;
  </code></pre>
  
  <p>The user control does not display the data ! Why ?</p>
  
  <p><code>Edit</code></p>
  
  <p>I added this to the code behind of the page :</p>
  
  <pre><code>public static readonly DependencyProperty SelectedUserProperty = WpfDpHelper.Register&lt;UserListUc, User&gt;(i =&gt; i.SelectedUser, Callback);
  
  private static void Callback(UserListUc userListUc, DependencyPropertyChangedEventArgs&lt;User&gt; DependencyPropertyChangedEventArgs)
  {
      Debug.WriteLine("user selection changed");
  }
  </code></pre>
  
  <p>And when I change the selection of any user the setter gets fired</p>
  
  <p><code>Second edit</code> : The user control</p>
  
  <pre><code>&lt;UserControl ...
               DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt;
      &lt;ListView ItemsSource="{Binding CurrentUser.CommentList}"&gt;
          &lt;!-- I want to show the user comments --&gt;
      &lt;/ListView&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p><code>Code behind</code></p>
  
  <pre><code>public static readonly DependencyProperty CurrentUserProperty = WpfDpHelper.Register&lt;UserUc, User&gt;(i =&gt; i.CurrentUser);
  public User CurrentUser
  {
      get { return (User) GetValue(CurrentUserProperty); }
      set { SetValue(CurrentUserProperty, value); }
  }
  </code></pre>