How do I bind the DateTime Property (return value for GetDateTime())
of a class implementing ITimeIndicator to a Property of my ViewModel?
my thoughts:
<telerik:RadScheduleView.TimeIndicatorsCollection>
<telerik:TimeIndicatorsCollection>
<local:CustomTimeIndicator Location="WholeArea" Now="{Binding CurrentNow}" />
</telerik:TimeIndicatorsCollection>
</telerik:RadScheduleView.TimeIndicatorsCollection>
public class CustomTimeIndicator : DependencyObject, ITimeIndicator
{
public static readonly DependencyProperty NowProperty = DependencyProperty.RegisterAttached("Now", typeof(DateTime), typeof(CustomTimeIndicator));
public DateTime Now
{
get => (DateTime)GetValue(NowProperty);
set => SetValue(NowProperty, value);
}
public DateTime GetDateTime()
{
return Now;
}
public TimeSpan Offset { get; set; }
public CurrentTimeIndicatorLocation Location { get; set; }
}
Gives me:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=CurrentNow; DataItem=null; target element is 'CustomTimeIndicator' (HashCode=47896050); target property is 'Now' (type 'DateTime')