title: Bind Tooltip Visibility to variable so that it shows text conditionally in code-behind
body: <p>If I have a class that holds a static variable that will contain the Visiblity status of a Tooltip, how would I write the code-behind to dynamically change the Tooltip visiblity when the visiblity variable changes?</p>
  
  <p>i.e. When Tooltip option is disabled, no Tooltips should be shown, but when Tooltip option is enabled, Tooltips should show up. (Tooltip option is held in a static variable in a different class) The Tooltip and the control it is connecting onto are dynamically created.</p>
  
  <p>Pseudocode:</p>
  
  <pre><code> ToolTip myToolTip = new ToolTip();
   Visiblity tooltipVis = Visibility.Visible;
   Bind myToolTip.Visiblity to toolTipVis
   //Any control with ToolTip should now show their respective ToolTip messages.
   ...
   tooltipVis = Visibility.Hidden;
   //Any control with ToolTip should now have ToolTip messages disabled
  </code></pre>
  
  <p>Attempt at binding to TreeViewItem:</p>
  
  <pre><code> TreeViewItem tvi = new TreeViewItem() { Header = tviHeader };
   ToolTip x = new System.Windows.Controls.ToolTip();
   x.Content = "This is text.";
   Binding binder = new Binding { 
        Source = EnvironmentalVariables.ToolTipVisibility,
        Path = new PropertyPath("Visibility")
   };
   x.SetBinding(VisibilityProperty, binder);
   user.ToolTip = x;
  
   public class EnvironmentalVariables {
        public static Visibility ToolTipVisibility { get; set; }
   }
  </code></pre>
  
  <p>This doesn't seem to bind the Visiblity to the EnvironmentalVariables.ToolTipVisibility variable.</p>