title: WPF invoke a control
body: <p>How can I invoke a control with parameters? I've googled this up, but nowhere to find!</p>
  
  <p><a href="http://www.google.nl/search?num=100&amp;hl=en&amp;newwindow=1&amp;safe=off&amp;client=firefox-a&amp;rls=org.mozilla%3Aen-US%3Aofficial&amp;q=WPF+invoke+ui+thread&amp;aq=f&amp;aqi=g1&amp;aql=&amp;oq=&amp;gs_rfai=" rel="noreferrer">invoke ui thread</a></p>
  
  <p>This is the error i get:</p>
  
  <blockquote>
    <p>Additional information: Parameter count mismatch.</p>
  </blockquote>
  
  <p>And this happens when i do a simple check whether the text property of a textbox control is empty or not. This works in WinForms:</p>
  
  <pre><code>if (this.textboxlink.Text == string.Empty)
     SleepThreadThatIsntNavigating(5000);
  </code></pre>
  
  <p>It jumps from this if the line to the catch block and shows me that message.</p>
  
  <p>This is how i try to invoke the control:</p>
  
  <pre><code>// the delegate:
  private delegate void TBXTextChanger(string text);
  
  private void WriteToTextBox(string text)
  {
      if (this.textboxlink.Dispatcher.CheckAccess())
      {
          this.textboxlink.Text = text;
      }
      else
      {
          this.textboxlink.Dispatcher.Invoke(
              System.Windows.Threading.DispatcherPriority.Normal,
              new TBXTextChanger(this.WriteToTextBox));
      }
  }
  </code></pre>
  
  <p>What am I doing wrong? And since when do i have to invoke a control when i just want to read its content?</p>