title: Dependency Property UserControl Binding not working
body: <p>My project is implemented in MVVM. I have a MainWindow, which consists of a statusbar and a tabview. Inside the tabview, there is a UserControl called "AnnotationView". Annotationview is the parent of two smaller usercontrols, called TimePicker. TimePicker consists of two textboxes, one for hours and one for minutes. I want to use this UserControl two times (that's also why I made it a Control of its own, to reuse it later on).</p>
  
  <p>XAML of TimePicker:</p>
  
  <pre><code>&lt;UserControl x:Class="archidb.Views.TimePicker"
               x:Name="TimePickerControl"
               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:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" Height="Auto" Width="Auto"
               KeyboardNavigation.TabNavigation="Local"&gt;
  
      &lt;Grid DataContext="{Binding ElementName=TimePickerControl}"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition/&gt;
              &lt;ColumnDefinition Width="5"/&gt;
              &lt;ColumnDefinition/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;TextBox Style="{StaticResource TextBoxStyle}"
                   Text="{Binding Path=HourValue}"
                   x:Name="tbHours"
                   KeyboardNavigation.TabIndex="0"/&gt;
          &lt;TextBlock Style="{StaticResource TextBlockStyle}"
                     Margin="0 -3 0 5"
                     Text=":"
                     Grid.Column="1"/&gt;
          &lt;TextBox Grid.Column="2" Style="{StaticResource TextBoxStyle}"
                   Text="{Binding Path=MinuteValue}"
                   x:Name="tbMinutes"
                   KeyboardNavigation.TabIndex="1"/&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>TimePicker Code-Behind:</p>
  
  <pre><code>public partial class TimePicker : UserControl
  {
      public static readonly DependencyProperty HourValueProperty = DependencyProperty.Register("HourValue", typeof(string), typeof(TimePicker), new PropertyMetadata("00"));
      public string HourValue
      {
          get { return (string)GetValue(HourValueProperty); }
          set { SetValue(HourValueProperty, value); }
      }
  
      public static readonly DependencyProperty MinuteValueProperty = DependencyProperty.Register("MinuteValue", typeof(string), typeof(TimePicker), new PropertyMetadata("00"));
      public string MinuteValue
      {
          get { return (string)GetValue(MinuteValueProperty); }
          set { SetValue(MinuteValueProperty, value); }
      }
  
      public TimePicker()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>In the AnnotationControl, I insert the UserControls like this:</p>
  
  <pre><code>&lt;v:TimePicker x:Name="tpStart"
                HourValue="{Binding Path=StartHours}"
                MinuteValue="{Binding Path=StartMinutes}"
                KeyboardNavigation.TabIndex="2"/&gt;
  
  &lt;v:TimePicker x:Name="tpEnde"
                HourValue="{Binding Path=EndHours}"
                MinuteValue="{Binding Path=EndMinutes}"
                KeyboardNavigation.TabIndex="3"
                Grid.Row="2"/&gt;
  </code></pre>
  
  <p>DataContext of AnnotationControl is set to its viewmodel, where I declared the properties.</p>
  
  <p>The problem is, the binding is not working. The default value I set in the dependency property ("00") is not showing in any of the textboxes. Also if I write something in the textboxes, the property in the viewmodel of AnnotationControl doesn't change its value. This problem has been bugging me for several days now, what am I doing wrong here?</p>