title: WPF: PropertyChangedCallback triggered only once
body: <p>I have a user control, which exposes a DependencyProperty called VisibileItems
  Every time that property gets updated, i need to trigger another event. 
  To achieve that, i added a FrameworkPropertyMetadata with PropertyChangedCallback event. </p>
  
  <p>For some reason, this event gets called only once, and doesn't trigger the next time VisibleItems is changed. </p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;cc:MyFilterList VisibleItems="{Binding CurrentTables}"  /&gt;
  </code></pre>
  
  <p>CurrentTables is a DependencyProperty on MyViewModel. CurrentTables gets changed often. I can bind another WPF control to CurrentTables, and i see the changes in the UI. </p>
  
  <p>Here is the way i wired VisibleItems with PropertyChangedCallback </p>
  
  <pre><code>public static readonly DependencyProperty VisibleItemsProperty =
      DependencyProperty.Register(
      "VisibleItems",
      typeof(IList),
      typeof(MyFilterList),
      new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(VisiblePropertyChanged))
  
      );
  
  public IList VisibleItems {
      get { return (IList)GetValue(VisibleItemsProperty); }
      set { SetValue(VisibleItemsProperty, value); }
  }
  </code></pre>
  
  <p>by stepping into VisiblePropertyChanged, i can see that it gets triggered the first time CurrentTables gets set. but not subsequent times. </p>
  
  <p>UPDATE</p>
  
  <p>as some of you questioned the way CurrentTables is modified, it is re-assigned completely on change: </p>
  
  <pre><code>OnDBChange()...
  CurrentTables = new List&lt;string&gt;(MainDatabaseDataAdapter.GetTables(this.SelectedServer, this.SelectedDatabase));
  </code></pre>
  
  <p>this line gets called on every change, but my VisiblePropertyChanged handler gets called only the first time. </p>
  
  <p>UPDATE</p>
  
  <p>if i assign VisibleItems directly, the handler does get called every time! </p>
  
  <pre><code>TestFilterList.VisibleItems = new List&lt;string&gt;( Enumerable.Range(1, DateTime.Now.Second).ToList().Select(s =&gt; s.ToString()).ToList() );
  </code></pre>
  
  <p>So, it looks like the problem stems from the DependencyProperty (VisibleItems) watching another DependencyProperty (CurrentTables). Somehow the binding works on first property change, but not on subsequent ones?
  Attempting to inspect this issue with snoop as some of you suggested. </p>