當前位置: 首頁>>代碼示例>>C#>>正文


C# Calendar類代碼示例

本文整理匯總了C#中System.Windows.Controls.Calendar的典型用法代碼示例。如果您正苦於以下問題:C# Calendar類的具體用法?C# Calendar怎麽用?C# Calendar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Calendar類屬於System.Windows.Controls命名空間,在下文中一共展示了Calendar類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Calendar

// Create a Calendar that displays 1/10/2009
  // through 4/18/2009.
  Calendar basicCalendar = new Calendar();
  basicCalendar.DisplayDateStart = new DateTime(2009, 1, 10);
  basicCalendar.DisplayDateEnd = new DateTime(2009, 4, 18);
  basicCalendar.DisplayDate = new DateTime(2009, 3, 15);
  basicCalendar.SelectedDate = new DateTime(2009, 2, 15);

  // root is a Panel that is defined elswhere.
  root.Children.Add(basicCalendar);

  // Create a Calendar that displays dates through
  // Januarary 31, 2009 and has dates that are not selectable.
  Calendar calendarWithBlackoutDates = new Calendar();
  calendarWithBlackoutDates.IsTodayHighlighted = false;
  calendarWithBlackoutDates.DisplayDate = new DateTime(2009, 1, 1);
  calendarWithBlackoutDates.DisplayDateEnd = new DateTime(2009, 1, 31);
  calendarWithBlackoutDates.SelectionMode = CalendarSelectionMode.MultipleRange;

  // Add the dates that are not selectable.
  calendarWithBlackoutDates.BlackoutDates.Add(
      new CalendarDateRange(new DateTime(2009, 1, 2), new DateTime(2009, 1, 4)));
  calendarWithBlackoutDates.BlackoutDates.Add(
      new CalendarDateRange(new DateTime(2009, 1, 9)));
  calendarWithBlackoutDates.BlackoutDates.Add(
      new CalendarDateRange(new DateTime(2009, 1, 16)));
  calendarWithBlackoutDates.BlackoutDates.Add(
      new CalendarDateRange(new DateTime(2009, 1, 23), new DateTime(2009, 1, 25)));
  calendarWithBlackoutDates.BlackoutDates.Add(
      new CalendarDateRange(new DateTime(2009, 1, 30)));

  // Add the selected dates.
  calendarWithBlackoutDates.SelectedDates.Add(
      new DateTime(2009, 1, 5));
  calendarWithBlackoutDates.SelectedDates.AddRange(
      new DateTime(2009, 1, 12), new DateTime(2009, 1, 15));
  calendarWithBlackoutDates.SelectedDates.Add(
      new DateTime(2009, 1, 27));

  // root is a Panel that is defined elswhere.
  root.Children.Add(calendarWithBlackoutDates);
開發者ID:.NET開發者,項目名稱:System.Windows.Controls,代碼行數:41,代碼來源:Calendar


注:本文中的System.Windows.Controls.Calendar類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。