static PersianCalendar() { PropertyMetadata displayModeMetaData = new PropertyMetadata(modeChanged); DisplayModeProperty = DependencyProperty.Register("DisplayMode", typeof(CalendarMode), typeof(PersianCalendar), displayModeMetaData); PropertyMetadata displayDateMetaData = new PropertyMetadata(Mohsen.PersianDate.Today, modeChanged); displayDateMetaData.CoerceValueCallback = coerceDateToBeInRange; DisplayDateProperty = DependencyProperty.Register("DisplayDate", typeof(Mohsen.PersianDate), typeof(PersianCalendar), displayDateMetaData); PropertyMetadata selectedDateMetaData = new PropertyMetadata(Mohsen.PersianDate.Today, (DependencyObject d, DependencyPropertyChangedEventArgs e) => { PersianCalendar pc = d as PersianCalendar; pc.selectedDateCheck((Mohsen.PersianDate)e.OldValue); pc.RaiseEvent(new RoutedEventArgs(SelectedDateChangedEvent, pc)); } ); selectedDateMetaData.CoerceValueCallback = coerceDateToBeInRange; SelectedDateProperty = DependencyProperty.Register("SelectedDate", typeof(Mohsen.PersianDate), typeof(PersianCalendar), selectedDateMetaData); PropertyMetadata displayDateStartMetaData = new PropertyMetadata { DefaultValue = new Mohsen.PersianDate(), CoerceValueCallback = new CoerceValueCallback(coerceDisplayDateStart), PropertyChangedCallback = new PropertyChangedCallback(DisplayDateStartChanged), }; DisplayDateStartProperty = DependencyProperty.Register("DisplayDateStart", typeof(Mohsen.PersianDate), typeof(PersianCalendar), displayDateStartMetaData); PropertyMetadata displayDateEndMetaData = new PropertyMetadata { DefaultValue = new Mohsen.PersianDate(10000, 1, 1), CoerceValueCallback = new CoerceValueCallback(coerceDisplayDateEnd), PropertyChangedCallback = new PropertyChangedCallback(DisplayDateEndChanged), }; DisplayDateEndProperty = DependencyProperty.Register("DisplayDateEnd", typeof(Mohsen.PersianDate), typeof(PersianCalendar), displayDateEndMetaData); PropertyMetadata todayBackgroundMetaData = new PropertyMetadata(Brushes.AliceBlue, (DependencyObject d, DependencyPropertyChangedEventArgs e) => { PersianCalendar pc = d as PersianCalendar; pc.todayCheck(); } ); TodayBackgroundProperty = DependencyProperty.Register("TodayBackground", typeof(Brush), typeof(PersianCalendar), todayBackgroundMetaData); SelectedDateChangedEvent = EventManager.RegisterRoutedEvent("SelectedDateChanged", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PersianCalendar)); }
static void modeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { PersianCalendar pc = d as PersianCalendar; pc.setCalendar(); }