title: WPF User control binding issue
body: <p>This should be a very simple case, but I am pulling hair trying to get it to work. Here is the setup:</p>
  
  <p>I am designing an app that will have an read-only mode and edit mode for some data. So I created a User Control which is a textbox and textblock bound to the same text data and are conditionally visible based on EditableMode property (so when it's editable the textbox is shown and when it's not the textblock is shown)</p>
  
  <p>Now, I want to have many of these controls in my main window and have them all bound too a single bool property. When that property is changed via a button, I want all TextBlocks to turn into TextBoxes or back. </p>
  
  <p>My problem is that the control is set correctly on binding, and if I do myUserControl.Editable = true. But it doesn't change if bind it to a bool property.</p>
  
  <p>Here is the code for my user control:</p>
  
  <pre><code>&lt;UserControl x:Class="CustomerCareTool.Controls.EditableLabelControl"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:src="clr-namespace:CustomerCareTool.Converters"
  DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt;
  &lt;UserControl.Resources&gt;
      &lt;src:BoolToVisibility x:Key="boolToVisibility" Inverted="False" /&gt;
      &lt;src:BoolToVisibility x:Key="invertedBoolToVisibility" Inverted="True" /&gt;
  &lt;/UserControl.Resources&gt;
  &lt;Grid&gt;
      &lt;TextBlock Name="textBlock" Text="{Binding Path=TextBoxValue}" Visibility="{Binding Path=EditableMode, Converter={StaticResource invertedBoolToVisibility}}"/&gt;
      &lt;TextBox Name="textBox" Visibility="{Binding Path=EditableMode, Converter={StaticResource boolToVisibility}}"&gt;
          &lt;TextBox.Text&gt;
              &lt;Binding Path="TextBoxValue" UpdateSourceTrigger="PropertyChanged"/&gt;
          &lt;/TextBox.Text&gt;
      &lt;/TextBox&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>I used a converter to convert bool to visibility and inverse bool to visibility. Not sure if that's at all needed here. </p>
  
  <p>And this is the code behind:</p>
  
  <pre><code>public partial class EditableLabelControl : UserControl
  {
      public EditableLabelControl()
      {
          InitializeComponent();
      }
  
      public string TextBoxValue
      {
          get { return (string)GetValue(TextBoxValueProperty); }
          set { SetValue(TextBoxValueProperty, value); }
      }
  
      public static readonly DependencyProperty TextBoxValueProperty =
          DependencyProperty.Register("TextBoxValue", typeof(string), typeof(EditableLabelControl), new UIPropertyMetadata());
  
  
      public bool EditableMode
      {
          get { return (bool)GetValue(EditableModeProperty); }
          set { SetValue(EditableModeProperty, value); }
      }
  
      public static readonly DependencyProperty EditableModeProperty =
          DependencyProperty.Register("EditableMode", typeof(bool),typeof(EditableLabelControl), new UIPropertyMetadata(false, EditableModePropertyCallBack));
  
  static void EditableModePropertyCallBack(DependencyObject property,
  DependencyPropertyChangedEventArgs args)
      {
          var editableLabelControl = (EditableLabelControl)property;
          var editMode = (bool)args.NewValue;
  
          if (editMode)
          {
              editableLabelControl.textBox.Visibility = Visibility.Visible;
              editableLabelControl.textBlock.Visibility = Visibility.Collapsed;
          }
          else
          {
              editableLabelControl.textBox.Visibility = Visibility.Collapsed;
              editableLabelControl.textBlock.Visibility = Visibility.Visible; 
          }
      }
  }
  </code></pre>
  
  <p>Now in my main application I have the control added like this:</p>
  
  <pre><code>&lt;Controls:EditableLabelControl x:Name="testCtrl" EditableMode="{Binding Path=Editable}" TextBoxValue="John Smith" Grid.Row="0"/&gt;
  </code></pre>
  
  <p>For that same application the DataContext is set to self</p>
  
  <pre><code>DataContext="{Binding RelativeSource={RelativeSource Self}}"
  </code></pre>
  
  <p>And the code behind looks like this:</p>
  
  <pre><code>public partial class OrderInfoView : Window, INotifyPropertyChanged
  
  {
      public OrderInfoView()
      {
          InitializeComponent();
      }
  
      private void Button_Click_1(object sender, RoutedEventArgs e)
      {
          Editable = !Editable;
      }
  
      private bool _editable = false;
      public bool Editable
      {
          get
          {
              return _editable;
          }
          set
          {
              _editable = value;
              OnPropertyChanged("Editable");
          }
      }
  
      protected virtual void OnPropertyChanged(string propertyName)
      {
          if (PropertyChanged == null) return;
  
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
  
  
      public event PropertyChangedEventHandler PropertyChanged;
  }
  </code></pre>
  
  <p>Clicking the button doesn't do anything :( I tried everything to get this to work, and no dice. Would really appreciate some help!</p>
  
  <hr>
  
  <p>I tried the following, and still does not work:</p>
  
  <pre><code>  public bool Editable
      {
          get { return (bool)GetValue(EditableProperty); }
          set { SetValue(EditableProperty, value); }
      }
  
      public static readonly DependencyProperty EditableProperty =
          DependencyProperty.Register("Editable", typeof(bool), typeof(OrderInfoView), new UIPropertyMetadata(false));
  </code></pre>