title: WPF Binding a Dependency Property
body: <p>I am having an issue binding a dependency property in a UserControl. When it initializes it gets a value but then it will not update.  I've probably missed something obvious, here are some code snippets:</p>
  
  <p>This is where I bind the <code>BalanceContent</code> dependency property:</p>
  
  <pre><code>&lt;Game:PlayerDetails x:Name="SelectedPlayerDetails" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Grid.RowSpan="4" 
                            BalanceContent="{Binding Source={StaticResource UserData}, Path=SelectedUser.Balance, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"&gt;
  
      &lt;/Game:PlayerDetails&gt;
  </code></pre>
  
  <p>Here is the <code>TextBox</code> in the <code>UserControl</code>:</p>
  
  <pre><code> &lt;TextBox  VerticalAlignment="Center" FontFamily="Formata" FontSize="20" Grid.Column="2" 
           Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}, Path=BalanceContent}" 
               Grid.Row="7"&gt;&lt;/TextBox&gt;
  </code></pre>
  
  <p>Here is the Dependency Property:</p>
  
  <pre><code>public static readonly DependencyProperty BalanceContentProperty = DependencyProperty.Register(
          "BalanceContent", typeof(string), typeof(PlayerDetails));
  
      public string BalanceContent
      {
          get
          {return (string) GetValue(BalanceContentProperty);}
          set
          {SetValue(BalanceContentProperty, value);}
      }
  </code></pre>
  
  <p>Here is the list where the selected user is updated, which is in a view that uses the UserControl:</p>
  
  <pre><code>&lt;ListView x:Name="lstAccounts"  Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Grid.RowSpan="4" 
                ItemsSource="{Binding Source={StaticResource UserData}, Path=CurrentUserSearch}" 
                SelectedItem="{Binding Source={StaticResource UserData}, Path=SelectedUser}"
  </code></pre>
  
  <p>And <code>SelectedUser</code> is defined here in a class that implements <code>INotifyPropertyChanged</code>:</p>
  
  <pre><code> public User SelectedUser
      {
          get
          {
              return _selectedUser;
          } 
          set
          {
              _selectedUser = value;
              OnPropertyChanged(new PropertyChangedEventArgs("SelectedUser"));
          }
      }
  </code></pre>
  
  <p>The idea is that the TextBox should update when a new user is selected in the list but at the moment it is not doing so.  I've put the binding on local TextBox and it updates fine, just not on a <code>DependencyProperty</code>. Any help appreciated.</p>