title: WPF - Trouble binding ToolTip text on custom user control
body: <p>I'm in the process of creating a simple user control; just an ImageButton.</p>
  
  <p>I've already successfully bound the Image to the button and so I've decided to add a tooltip.  Now I'm having troubles.  It seems that I can hard-code the text for the tooltip in the XAML for the control, but when it's bound it's returning an empty string.</p>
  
  <p>Here's the XAML for my control:</p>
  
  <pre><code>&lt;Button x:Class="BCOCB.DACMS.Controls.ImageButton"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300"
          Name="this"
          Style="{StaticResource DisabledButton}"&gt;
  
      &lt;Image Source="{Binding ElementName=this, Path=Source}" /&gt;    
      &lt;Button.ToolTip&gt;
          &lt;TextBlock Text="{Binding ElementName=this, Path=ToolTipText}" /&gt;
      &lt;/Button.ToolTip&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p>And here's the dependency property info for the tooltip text:</p>
  
  <pre><code>public static readonly DependencyProperty ToolTipTextProperty = DependencyProperty.Register("ToolTipText", typeof(string), typeof(ImageButton));
  public string ToolTipText
  {
    get
    {
      return this.GetValue(ToolTipTextProperty) as string;
    }
    set
    {
      this.SetValue(ToolTipTextProperty, value);
    }
  }
  </code></pre>
  
  <p>And, finally, the declaration of the control in my Window:</p>
  
  <pre><code>&lt;controls:ImageButton x:Name="btnAdd" Source="/DACMS;component/Resources/plus.png" ToolTipText="Add New Item" Click="btnAdd_Click" /&gt;
  </code></pre>
  
  <p>As I mentioned before, the image binds just fine and I've done it in exactly the same manner.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks,<br />
  Sonny</p>
  
  <p>EDIT:  I have it working now.  I've removed the ElementName from the binding and set the TextBlock's <code>DataContext = this</code> in the code behind on instanciation.  Still, I'd like to know how to fix this in the XAML, instead.</p>