title: Set TextBlock Visibility based on a bound bool
body: <p>I am trying to link the visibility of a TextBlock to a bool property which is also linked to a checkbox using WPF and c#. I have the following code in two different sections of the same xaml file (one section is a summary, and the other is settings. I am very new to WPF, and am learning as I go. Currently, the TextBlock is visible no matter what the value of IsSecondaryMessageFilePath is.</p>
  
  <pre><code>&lt;TextBlock Name="secondaryfolderinfo" Foreground="Red"&gt;
      &lt;ContentControl Content="Secondary message folder" Foreground ="Black" /&gt;                    
      &lt;ContentControl Content = "{Binding Path=SecondaryMessageFilePath}" ContentStringFormat="" ClipToBounds="False"&gt;&lt;/ContentControl&gt;
      &lt;ContentControl Content = "   "&gt;&lt;/ContentControl&gt;
      &lt;TextBlock.Style&gt;
          &lt;Style TargetType="{x:Type TextBlock}"&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding Path=IsSecondaryMessageFilePath}" Value="True"&gt;
                      &lt;Setter Property="Visibility" Value="Visible"&gt;&lt;/Setter&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/TextBlock.Style&gt;
  &lt;/TextBlock&gt;
  </code></pre>
  
  <p>Further down I have:</p>
  
  <pre><code>&lt;CheckBox IsChecked="{Binding Path=IsSecondaryMessageFilePath, Mode=TwoWay}"
      Name="SecondaryPathCheckBox"
      VerticalAlignment="Top"
      HorizontalAlignment="Left"
      Margin="320,7,0,0"&gt;Save additional locations&lt;/CheckBox&gt;
  </code></pre>
  
  <p>Finally, in the code-behind, I have:</p>
  
  <pre><code>public bool IsSecondaryMessageFilePath
  {
      get { return _isSecondaryMessageFilePath; }
      set
      {
          if (_isSecondaryMessageFilePath != value)
          {
              _isSecondaryMessageFilePath = value;
              OnPropertyChanged("IsSecondaryMessageFilePath");
          }
      }
  }
  private bool _isSecondaryMessageFilePath;
  
  public string SecondaryMessageFilePath
  {
      get { return _secondaryMessageFilePath; }
      set
      {
          if (_secondaryMessageFilePath != value)
          {
              _secondaryMessageFilePath = value;
              OnPropertyChanged("SecondaryMessageFilePath");
          }
      }
  }
  private string _secondaryMessageFilePath;
  </code></pre>
  
  <p>Any assistance would be appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Working from the suggestion below, I tried adding the BooleanToVisibilityConverter, but am getting a missing assembly reference for it, and am to new to WPF to figure out how to resolve it. My opening code is as follows:</p>
  
  <pre><code>    &lt;UserControl x:Class="Sender_Receiver.SenderReceiverSetup"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
      xmlns:m=...
      xmlns:
  
      &lt;UserControl.Resources&gt;
          &lt;BooleanToVisibiltyConverter x:Key="BooleanToVisibilityConverter"/&gt;
  ...
  </code></pre>