I've created a custom control in a separate project and it worked correctly and I was able to bind to it from the main window.. I've copied it over to my working project and now I'm getting an error when I try to bind to it in the xaml designer.
A 'Binding' cannot be set on the 'CurrentDateTime' property of type 'MyApp_DTControl_9_356303148'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
<controls:DTControl Grid.Row="1" CurrentDateTime="{Binding SCI.CheckInTime}"/>
My DependencyProperty is declared in my control's code behind.
public static readonly DependencyProperty SetCurrentDateTimeProperty =
DependencyProperty.Register("CurrentDateTime",
typeof(DateTime), typeof(DTControl),
new PropertyMetadata(DateTime.Now, new PropertyChangedCallback(OnDateChanged)));
public DateTime CurrentDateTime {
get {
return (DateTime)GetValue(SetCurrentDateTimeProperty);
}
set {
SetValue(SetCurrentDateTimeProperty, value);
}
}
What's causing the designer to not recognize the DP?