title: Binding dependency property into another xaml
body: <p>I have created a dependency property in one of the usercontrols but need some way to bind it into another XAML(another usercontrol).Here is the C# code</p>
  
  <p>DateRangeSelectorControl.cs</p>
  
  <pre><code>public static readonly DependencyProperty TodayDateProperty =
      DependencyProperty.Register("TodayDate",
      typeof(DateTime),
      typeof(DateRangeSelectorControl),
      new PropertyMetadata(null, TodayDateChanged));
  </code></pre>
  
  <p>I have another XAML(ActivityListMenuControlView.xaml) where i need to bind this property(TodayDateProperty) so that it can be exposed and it's callback called.
  Here is the XAML code:</p>
  
  <pre><code>&lt;DateRangeSelector:DateRangeSelectorControl x:Name="DateRangeSelector"
                                              Grid.Column="1"
                                              Margin="10 0 0 0"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Center"
                                              AutomationProperties.AutomationId="AID_TaskListDateRangeSelector"
                                              DateRangeUpdatedCmd="{Binding Path=DateRangeSelectionUpdatedCommand}"
                                              FontSize="{StaticResource TaskListMenuFontSize}"
                                              RangeOptions="{Binding Path=DateRangeSelectionOptions,
                                                                     Mode=OneTime}"
                                              SelectedDateRange="{Binding Path=SelectedRange,
                                                                          Mode=TwoWay}"
                                              Visibility="{Binding Path=ShowFilterOptions,
                                                                   Converter={StaticResource boolToVisibility}}" /&gt;
  </code></pre>
  
  <p>Is there any way?</p>
  
  <p>UPDATE:
  As per the suggestion from O.R Mapper, i have made the following change into this XAML(ActivityListMenuControlView.xaml):</p>
  
  <blockquote>
  <pre><code>        &lt;DateRangeSelector:DateRangeSelectorControl x:Name="DateRangeSelector"
                                                      Grid.Column="1"
                                                      Margin="10 0 0 0"
                                                      HorizontalAlignment="Left"
                                                      VerticalAlignment="Center"
                                                      AutomationProperties.AutomationId="AID_TaskListDateRangeSelector"
                                                      DateRangeUpdatedCmd="{Binding Path=DateRangeSelectionUpdatedCommand}"
                                                      FontSize="{StaticResource TaskListMenuFontSize}"
                                                      RangeOptions="{Binding Path=DateRangeSelectionOptions,
                                                                             Mode=OneTime}"
                                                      SelectedDateRange="{Binding Path=SelectedRange,
                                                                                  Mode=TwoWay}"
                                                      Visibility="{Binding Path=ShowFilterOptions,
                                                                           Converter={StaticResource boolToVisibility}}"
                                                      TodayDateProperty="{Binding TodayDate, ElementName=DateRangeSelector}"
  </code></pre>
  </blockquote>
  
  <p>Still i get an error : Property or event expected. Upon compilation i get the following errors:</p>
  
  <p>Error   2   The property 'TodayDateProperty' was not found in type 'DateRangeSelectorControl'.
  Error   4   Default value type does not match type of property 'TodayDate'.</p>
  
  <p>Any idea?</p>
  
  <p>UPDATE:
  As suggested by Sheridan, i changed the XAML to something like:</p>
  
  <blockquote>
  <pre><code>        &lt;DateRangeSelector:DateRangeSelectorControl x:Name="DateRangeSelector"
                                                      Grid.Column="1"
                                                      Margin="10 0 0 0"
                                                      HorizontalAlignment="Left"
                                                      VerticalAlignment="Center"
                                                      AutomationProperties.AutomationId="AID_TaskListDateRangeSelector"
                                                      DateRangeUpdatedCmd="{Binding Path=DateRangeSelectionUpdatedCommand}"
                                                      FontSize="{StaticResource TaskListMenuFontSize}"
                                                      RangeOptions="{Binding Path=DateRangeSelectionOptions,
                                                                             Mode=OneTime}"
                                                      SelectedDateRange="{Binding Path=SelectedRange,
                                                                                  Mode=TwoWay}"
                                                      Visibility="{Binding Path=ShowFilterOptions,
                                                                           Converter={StaticResource boolToVisibility}}"
                                                      TodayDate="{Binding TodayDate, ElementName=DateRangeSelector}"/&gt;
  </code></pre>
  </blockquote>
  
  <p>Wrapper property "TodayDate" is defined in DateRangeSelector as below:</p>
  
  <p>DateRangeSelector.cs</p>
  
  <blockquote>
  <pre><code>    public DateTime TodayDate
      {
          get { return (DateTime)GetValue(TodayDateProperty); }
          set { SetValue(TodayDateProperty, value); }
      }
  </code></pre>
  </blockquote>
  
  <p>And in the viewmodel(ActivityListMenuControlViewModel.cs) i created another "TodayDate"(as specified in the binding) as belowL</p>
  
  <blockquote>
  <pre><code>    public DateTime TodayDate
      {
          get;
          set;
      }
  </code></pre>
  </blockquote>
  
  <p>On compilation i get the below errors:</p>
  
  <p>Error   2   The property 'TodayDate' was not found in type 'DateRangeSelectorControl'.
  Error   12  Default value type does not match type of property 'TodayDate'.</p>
  
  <p>Any help?</p>