如下一个依赖属性,添加元数据的时候用FrameworkPropertyMetadata而不用dataPropertyMedata
public DateTime SelctedDate
{
get { return (DateTime)GetValue(SelctedDateProperty); }
set { SetValue(SelctedDateProperty, value); }
}
// Using a DependencyProperty as the backing store for SelctedDate. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SelctedDateProperty =
DependencyProperty.Register("SelctedDate", typeof(DateTime), typeof(DateTimePicker), new FrameworkPropertyMetadata(DateTime.MinValue, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,SelectedDateChanged));