title: Dependency Property Binding - Assign a new value
body: <p>I've implemented a simple DependencyProperty on my WPF control to use it in Binding.</p>
  
  <pre><code>public static readonly DependencyProperty PollingProperty = DependencyProperty.Register("Polling", typeof(Polling), typeof(ConverterView), new UIPropertyMetadata(null));
  
  public Polling Polling
  {
      get { return (Polling)GetValue(PollingProperty); }
      set { SetValue(PollingProperty, value); }
  }
  </code></pre>
  
  <p>The control itself is set as DataContext, so in XAML I just use it like this:</p>
  
  <pre><code>&lt;ProgressBar Height="25" Value="{Binding Path=Polling.Progress, Mode=OneWay}" /&gt;
  </code></pre>
  
  <p>Polling.Progress is an integer property that implements INoftiyPropertyChanged, so changes get promoted to the UI. Everything works fine and changes on "Progress" are shown in the ProgressBar as expected. </p>
  
  <p>However there is a certain point in my application where a new "Polling"-instance is applied to the DependencyProperty.</p>
  
  <pre><code>Polling = new Polling(); Polling.Start();
  </code></pre>
  
  <p>After that, the binding is no longer evaluated and the ProgressBar stays at the last value of the old instance.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>As my case is maybe a little bit specific I'll explain a bit more.</p>
  
  <p>A Button on my ConverterView WPF-Control allows the user to start an operation:</p>
  
  <pre><code>private void cmdAusformatieren_Click(object sender, RoutedEventArgs e)
  {
      Polling = Document.Converter(ConvertFinished);
  }
  </code></pre>
  
  <p>The Convert-method takes a delegate as parameter, which will be invoked after the operation is finished. (The whole process runs asynchronous.)
  The Convert-Method returns a <strong>Polling</strong>-object which provides an integer property Progress, that provides the information I want to display in a ProgressBar.
  (What may be misleading here, Polling is the name of my DependencyProperty as well as the name of my class).</p>
  
  <p>As far as this, everything seems ok and the Binding to Polling.Progress works.</p>
  
  <p>In my event ConvertFinished() which triggers after the first operation is done, I get a new Polling instance returned and want to use this in Binding from then on.</p>
  
  <pre><code>private void ConvertFinished(object result)
  {           
      Polling = Document.Format((byte[])result, FormatFinished);
  }
  </code></pre>
  
  <p>After this assignment to my Polling DependencyProperty, the Binding is no longer updated and stays with its previous value.</p>