Calendar.SelectedDates 속성

정의

선택한 날짜의 컬렉션을 가져옵니다.Gets a collection of selected dates.

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 개체입니다.A SelectedDatesCollection object that contains the currently selected dates. 기본값은 빈 컬렉션입니다.The default is an empty collection.

예제

다음 예제에서는 Calendar 선택한 날짜 범위를 여러 개 포함 합니다.The following example creates a Calendar that has multiple ranges of dates selected.

  // 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 메서드.Dates can be added to the collection either individually or in a range using the AddRange method. 값에 따라는 SelectionMode 속성을 날짜 또는 범위를 컬렉션에 추가 있기 지워집니다.Depending on the value of the SelectionMode property, adding a date or range to the collection may cause it to be cleared. 다음 표에서 어떻게 CalendarSelectionMode 영향을 줍니다는 SelectedDates 속성입니다.The following table lists how CalendarSelectionMode affects the SelectedDates property.

CalendarSelectionModeCalendarSelectionMode DescriptionDescription
None 선택할 수 없습니다.No selections are allowed. SelectedDate 설정할 수 없습니다 값이 없는 추가할 수 있습니다 및 SelectedDates합니다.SelectedDate cannot be set and no values can be added to SelectedDates.
SingleDate 단일 날짜를 선택할 수 있습니다를 설정 하거나 SelectedDate 값과 첫 번째 SelectedDates입니다.Only a single date can be selected, either by setting SelectedDate or the first value in SelectedDates. AddRange 사용할 수 없습니다.AddRange cannot be used.
SingleRange 하나의 날짜 범위를 선택할 수 있습니다.A single range of dates can be selected. 설정 SelectedDate, 날짜를 개별적으로 추가 SelectedDates를 알거나 AddRange 에서 모든 이전 값이 지워집니다 SelectedDates합니다.Setting SelectedDate, adding a date individually to SelectedDates, or using AddRange will clear all previous values from SelectedDates.
MultipleRange 연속되지 않는 날짜 범위 여러 개를 선택할 수 있습니다.Multiple non-contiguous ranges of dates can be selected. 날짜를 개별적으로 추가 SelectedDates 알거나 AddRange 지워지지 것입니다. SelectedDates합니다.Adding a date individually to SelectedDates or using AddRange will not clear SelectedDates. 설정 SelectedDate 지워집니다 여전히 SelectedDates, 하지만 추가 날짜 또는 범위 추가할 수 있습니다.Setting SelectedDate will still clear SelectedDates, but additional dates or ranges can then be added. 이미 선택 되어 있고 공용 구조체에 다른 범위 결과 범위와 겹치는 경우 예외가 발생 하지 않습니다는 일부 날짜를 포함 하는 범위를 추가 합니다.Adding a range that includes some dates that are already selected or overlaps with another range results in the union of the ranges and does not cause an exception.

XAML 속성 요소 사용XAML Property Element Usage

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

XAML 값XAML Values

oneOrMoreDateTimeObjectsoneOrMoreDateTimeObjects
하나 이상의 DateTime 개체 요소입니다.One or more DateTime object elements.

적용 대상