这个点击月份的时候就自动进去选择几号的了
能不能到选择月份就终止了?
------解决方案--------------------------------------------------------
楼主可以修改Silverlight Toolkit代码实现,创建一个新的依赖属性实现。
可以参考以下代码可以实现Calendar只选月份:
public CalendarMode CalendarMode
{
get { return (CalendarMode)GetValue(CalendarModeProperty); }
set { SetValue(CalendarModeProperty, value); }
}
public static readonly DependencyProperty CalendarModeProperty =
DependencyProperty.Register(
"CalendarMode",
typeof(CalendarMode),
typeof(DatePicker),
new PropertyMetadata(OnCalendarModeChanged));
private static void OnCalendarModeChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
DatePicker dp = d as DatePicker;
// get the new value into a calendar mode variable.
CalendarMode cm = (CalendarMode)e.NewValue;
if (dp != null)
{
dp._calendar.DisplayMode = cm;
}
}
private void InitializeCalendar()
{
_calendar = new Calendar();
_calendar.DayButtonMouseUp += new MouseButtonEventHandler(Calendar_DayButtonMouseUp);
_calendar.DisplayDateChanged += new EventHandler<CalendarDateChangedEventArgs>
(Calendar_DisplayDateChanged);
_calendar.SelectedDatesChanged += new EventHandler<SelectionChangedEventArgs>
(Calendar_SelectedDatesChanged);
_calendar.MouseLeftButtonDown += new MouseButtonEventHandler
(Calendar_MouseLeftButtonDown);
_calendar.KeyDown += new KeyEventHandler(Calendar_KeyDown);
_calendar.SelectionMode = CalendarSelectionMode.SingleDate;
_calendar.SizeChanged += new SizeChangedEventHandler(Calendar_SizeChanged);
_calendar.IsTabStop = true;
#region Juan Mejia - Modification
_calendar.DisplayMode = this.CalendarMode;
_calendar.DisplayModeChanged += new EventHandler<CalendarModeChangedEventArgs>
(Calendar_DisplayModeChanged);
#endregion