title: How can I bind this Textblock inside ControlTemplate in button style?
body: <p>I have a <code>Button</code> style and this style contains an icon and a text. I would like to bind the text.
  How can I achieve that?</p>
  <pre><code>&lt;Style TargetType=&quot;{x:Type Button}&quot; x:Key=&quot;ConnectedButton&quot;&gt;
      &lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot;/&gt;
      &lt;Setter Property=&quot;FlowDirection&quot; Value=&quot;LeftToRight&quot;/&gt;
      &lt;Setter Property=&quot;Template&quot;&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType=&quot;{x:Type Button}&quot;&gt;
                  &lt;Border Padding=&quot;5 0&quot; 
                          Width=&quot;80&quot;
                          Height=&quot;30&quot;
                          Margin=&quot;5&quot;&gt;
                      &lt;StackPanel Orientation=&quot;Horizontal&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Center&quot;&gt;
                          &lt;TextBlock Text=&quot;{Binding Connect}&quot;  
                                     Margin=&quot;3 0&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Center&quot;/&gt;
                          &lt;TextBlock Text=&quot;{StaticResource ConnectIcon}&quot; 
     
                                     Style=&quot;{StaticResource Icon_Text}&quot;  Margin=&quot;3 0&quot;
                                     HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Center&quot;/&gt;
                      &lt;/StackPanel&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  <p>Use the style in <code>MainWindow.xaml</code>:</p>
  <pre><code>  &lt;Button Style=&quot;{StaticResource ConnectedButton}&quot; Margin=&quot;10,15,0,10&quot; x:Name=&quot;cnct_btn&quot; Content=&quot;{StaticResource Connect}&quot;  Height=&quot;40&quot; Width=&quot;80 &quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Center&quot;  Click=&quot;Cnct_Click&quot;/&gt;
  </code></pre>
  <p><code>MainWindow.xaml.cs</code></p>
  <pre><code>bool test = false;
  //...
  
  if (test)
  {
     cnct_btn.Content = &quot;Connect&quot;;
  }
  else 
  {
     cnct_btn.Content = &quot;Not Connected&quot;;
  }
  </code></pre>
  <p>I have tried <code>Text={Binding Connect}</code> but it doesn't work.</p>