title: WPF: how to make Text in a custom control show up?
body: <p>I have a custom button <code>MyButton</code> with a <code>Text</code> property defined as follows:</p>
  
  <pre><code>public static readonly DependencyProperty TextProperty =
      DependencyProperty.Register("Text", typeof(string), typeof(MyButton));
  
  public string Text
  {
      get { return GetValue(TextProperty) as string; }
      set { SetValue(TextProperty, value); }
  }
  </code></pre>
  
  <p>The <code>Text</code> property of <code>MyButton</code> is binded to an object's property:</p>
  
  <pre><code>&lt;local:MyButton Text="{Binding Path=SomeString}"/&gt;
  </code></pre>
  
  <p>I want the binded text to show up on a <code>TextBlock</code> inside <code>MyButton</code>, how to accomplish this?</p>
  
  <p>this was my first bad attempt, modifying the setter</p>
  
  <pre><code>set
  {
      SetValue(TextProperty, value);
      aTextBlock.Text = value.ToString(); //this is bad, from what i read
  }
  </code></pre>
  
  <p>but then saw this at wpftutorial.net/DependencyProperties.html</p>
  
  <blockquote>
    <p>Do not add any logic to these properties, because they are only called
    when you set the property from code. If you set the property from XAML
    the SetValue() method is called directly.</p>
  </blockquote>
  
  <p>Any help is appreciated!</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong> below is the xaml for <code>MyButton</code></p>
  
  <pre><code>&lt;UserControl ...&gt;
      &lt;Button HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" &gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="3*"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
  
              &lt;Viewbox Stretch="Uniform" Grid.Column="0"&gt;
                  &lt;TextBlock x:Name="aTextBlock" Text="{Binding Path=Text}"/&gt;
              &lt;/Viewbox&gt;
              &lt;Viewbox Grid.Column="1"&gt;
                  &lt;TextBlock Text="someText" /&gt;
              &lt;/Viewbox&gt;
          &lt;/Grid&gt;
      &lt;/Button&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>as shown, I tried to bind <code>Text</code> of <code>aTextBlock</code>, but that text never shows up; only "someText" from column 1 shows.</p>
  
  <p>doing this as suggested by @Krishna</p>
  
  <pre><code>&lt;TextBlock x:Name="aTextBlock" Text="{TemplateBinding Text}"/&gt;
  </code></pre>
  
  <p>won't compile with the error</p>
  
  <pre><code>The member "Text" is not recognized or is not accessible.
  </code></pre>
  
  <p>Sorry I know this should be simple, but can't yet get it to work. I am not using template for this control. Thanks!</p>