title: Can a UserControl hide itself via its own XAML
body: <p>If I have a user control that I want to act as an overlay, I would like to it hide itself, so to speak, when it is not needed.  It will know this by via a dependency property it has that the parent object can bind to.  My first thought would be to do this via the out most grid of the UC.  So Something like this:</p>
  
  <pre><code>&lt;UserControl x:Class="MyUserControl"
      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:valueConverters="clr-namespace:Some.Namespace;assembly=Some.Assembly"&gt;
  
      &lt;UserControl.Resources&gt;
          &lt;valueConverters:VisibilityConverter x:Key="VisibilityConverter"/&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}"
            Visibility="{Binding ShowMyself, Converter={StaticResource VisibilityConverter}}"&gt;&gt;
          .................
          .................
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>This works fine.  Now if I want to hide the control via the Parent object, that is easy enough with something like this:</p>
  
  <pre><code>&lt;controls:MyUserControl ShowMyself="{Binding ShowUserControl"&gt;
      .........
      .........
  &lt;/controls:MyUserControl&gt;
  </code></pre>
  
  <p>But I was wondering if it would be possible do do something like this so the control, essentially, hides itself:    </p>
  
  <pre><code>&lt;UserControl x:Class="MyUserControl"
      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:valueConverters="clr-namespace:Some.Namespace;assembly=Some.Assembly"&gt;
  
      &lt;UserControl.Resources&gt;
          &lt;valueConverters:VisibilityConverter x:Key="VisibilityConverter"/&gt;
      &lt;/UserControl.Resources&gt;
  
      &lt;UserControl.Visibility&gt;
          &lt;Binding Path="ShowMyself" Converter="{StaticResource VisibilityConverter}"/&gt;
      &lt;/UserControl.Visibility&gt;
  
      &lt;Grid&gt;
          .................
          .................
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>I realize there is probably little to no difference in practical terms and this may be purely academic but it would seem more "appropriate".  If I try the second scenario the problem becomes the Binding is outside the DataContext and cannot seen the property - the DataContext is now that of the parent object which makes sense since the UserControl tags themselves essentially contain no "meat".</p>
  
  <p>Is it just not possible?</p>