Calendar.SelectedDates 속성

정의

선택한 날짜의 컬렉션을 가져옵니다.

public:
 property System::Windows::Controls::SelectedDatesCollection ^ SelectedDates { System::Windows::Controls::SelectedDatesCollection ^ get(); };
public System.Windows.Controls.SelectedDatesCollection SelectedDates { get; }
member this.SelectedDates : System.Windows.Controls.SelectedDatesCollection
Public ReadOnly Property SelectedDates As SelectedDatesCollection

속성 값

SelectedDatesCollection

현재 선택한 날짜를 포함하는 SelectedDatesCollection 개체입니다. 기본값은 빈 컬렉션입니다.

예제

다음 예제에서는 Calendar 선택한 날짜 범위를 여러 개 포함 합니다.

  // 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);
' Create a Calendar that displays dates through 
' Januarary 31, 2009 and has dates that are not selectable. 
Dim calendarWithBlackoutDates As 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)
<!-- Create a Calendar that displays dates through
     Januarary 31, 2009 and has dates that are not selectable. -->
<Calendar Margin="20" SelectionMode="MultipleRange"  
          IsTodayHighlighted="false" 
          DisplayDate="1/1/2009"
          DisplayDateEnd="1/31/2009"
          xmlns:sys="clr-namespace:System;assembly=mscorlib">

  <Calendar.BlackoutDates>
    <CalendarDateRange Start="1/2/2009" End="1/4/2009"/>
    <CalendarDateRange Start="1/9/2009" End="1/9/2009"/>
    <CalendarDateRange Start="1/16/2009" End="1/16/2009"/>
    <CalendarDateRange Start="1/23/2009" End="1/25/2009"/>
    <CalendarDateRange Start="1/30/2009" End="1/30/2009"/>
  </Calendar.BlackoutDates>

  <Calendar.SelectedDates>
    <sys:DateTime>1/5/2009</sys:DateTime>
    <sys:DateTime>1/12/2009</sys:DateTime>
    <sys:DateTime>1/14/2009</sys:DateTime>
    <sys:DateTime>1/13/2009</sys:DateTime>
    <sys:DateTime>1/15/2009</sys:DateTime>
    <sys:DateTime>1/27/2009</sys:DateTime>
    <sys:DateTime>4/2/2009</sys:DateTime>
  </Calendar.SelectedDates>
</Calendar>

설명

개별적으로 또는 사용 하 여 범위에서 날짜를 컬렉션에 추가할 수 있습니다는 AddRange 메서드. 값에 따라는 SelectionMode 속성을 날짜 또는 범위를 컬렉션에 추가 있기 지워집니다. 다음 표에서 어떻게 CalendarSelectionMode 영향을 줍니다는 SelectedDates 속성입니다.

CalendarSelectionMode Description
None 선택할 수 없습니다. SelectedDate 설정할 수 없습니다 값이 없는 추가할 수 있습니다 및 SelectedDates합니다.
SingleDate 단일 날짜를 선택할 수 있습니다를 설정 하거나 SelectedDate 값과 첫 번째 SelectedDates입니다. AddRange 사용할 수 없습니다.
SingleRange 하나의 날짜 범위를 선택할 수 있습니다. 설정 SelectedDate, 날짜를 개별적으로 추가 SelectedDates를 알거나 AddRange 에서 모든 이전 값이 지워집니다 SelectedDates합니다.
MultipleRange 연속되지 않는 날짜 범위 여러 개를 선택할 수 있습니다. 날짜를 개별적으로 추가 SelectedDates 알거나 AddRange 지워지지 것입니다. SelectedDates합니다. 설정 SelectedDate 지워집니다 여전히 SelectedDates, 하지만 추가 날짜 또는 범위 추가할 수 있습니다. 이미 선택 되어 있고 공용 구조체에 다른 범위 결과 범위와 겹치는 경우 예외가 발생 하지 않습니다는 일부 날짜를 포함 하는 범위를 추가 합니다.

XAML 속성 요소 사용

<object>  
  <object.SelectedDates>  
    oneOrMoreDateTimeObjects  
  </object.SelectedDates>  
</object>  

XAML 값

oneOrMoreDateTimeObjects
하나 이상의 DateTime 개체 요소입니다.

적용 대상