我为DateTimePicker编写了一个自定义控件,但绑定值没有正确传递给属性。
<cc:DateTimePicker SelDate="{Binding RA_EFFECTIVE_DATE}"/> <!-- Doesn't work -->
<cc:DateTimePicker SelDate="1.1.2014"/> <!-- Works? Which means I can see the value inside setter SelDate correctly -->
这是我的DateTimePicker类:
public static readonly DependencyProperty SelDateProperty =
DependencyProperty.Register(
"SelDate",
typeof(DateTime?),
typeof(DateTimePicker),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedDateChanged, CoerceSelectedDate));
public DateTime? SelDate
{
get { return (DateTime?)GetValue(SelDateProperty); }
set { SetValue(SelDateProperty, value); }
}
提前致谢...