title: Binding the datacontext of a UserControl
body: <p>Having work a bit and thanks to the answer I am now using :</p>
  
  <pre><code>public class PopupProgramazione : DependencyObject
      {
          public static readonly DependencyProperty ShowProperty = DependencyProperty.Register("FirstNo", typeof(bool), typeof(PopupProgramazione), null);
  
          public bool Show
           {
              get { return (bool)GetValue(ShowProperty); }
              set { SetValue(ShowProperty, value); }
           }
      }
  </code></pre>
  
  <p>in my view Model:</p>
  
  <pre><code>   public PopupProgramazione Popup
      {
          get { return _Popup; }
          set
          {
              _Popup = value;
              RaisePropertyChanged("Popup");
          }
      }
  
      public void Programmazione(InterventoSchedeConsuntivi intervento)
      {
          Popup.Show = true;
          InterventoPopupProgramazione = intervento;
      }
  </code></pre>
  
  <p>the strange problem comes with the xaml :</p>
  
  <pre><code>&lt;local:PopupProgrammazione 
               x:Name="popupProg"
              Height="300" 
              Width="400"
              Canvas.ZIndex="2"
              Canvas.Left="150"
              Canvas.Top="150" Grid.RowSpan="4" Grid.Column="2" Margin="7,4,12,296"
              Visibility="{Binding Path=Popup.Show, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}"
              DataContext="{Binding Path=InterventoPopupProgramazione}"
              &gt;
          &lt;/local:PopupProgrammazione&gt;
  </code></pre>
  
  <p>If I have only Visibility set it works well and I can see that I am getting through the converter using the debug. </p>
  
  <p>If have both, then the initialisation of the popup is not made.( the popup is shown whereas Popup.Show=false). But If I close the popup :</p>
  
  <pre><code>private void Close_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
          {
              this.Visibility = Visibility.Collapsed;
          }
  </code></pre>
  
  <p>and then pass by my function to open it, it works but without passing by the converter.</p>
  
  <p>Could someone explain me what is going on there?</p>
  
  <p>[EDIT]
  Instead of binding specifically my usercontrol to a dedicated object, I use the datacontext of main xaml and then it works perfectly.
  [/EDIT]</p>