'宣言 Public ReadOnly Property SelectedDates As SelectedDateCollection
public SelectedDateCollection SelectedDates {get;}
SelectedDates はエンド ユーザーが選択された CalendarItem インスタンスを表す DateTime インスタンスのコレクションです。SelectionType が Range または Extended のような複数選択を許可する値に設定する場合、コントロールは 1 つ以上の CalendarItem の選択を許可します。各項目の 1 つの日付が SelectedDates に追加されます。SelectedDate プロパティは、最初の項目にアクセスするために使用できます。
注:MinCalendarMode が Days 以外の値に設定される場合、CalendarItem の選択は各選択された項目で 1 エントリーのみを追加します。項目の範囲の各日付を SelectedDates に追加しません。
Imports Infragistics.Windows.Editors Imports Infragistics.Windows.Editors.Events Imports Infragistics.Windows.Controls Private Sub InitializeCalendar(ByVal calendar As XamMonthCalendar) ' the selectiontype determines how dates may be selected ' Range is a special type of multiple selection that ignores ' the control key state and therefore doesn't allow ' discontigous sections via the ui calendar.SelectionType = SelectionType.Range ' use MaxSelectedDates to restrict the number of dates ' that can be selected calendar.MaxSelectedDates = 7 ' you can add individual dates to the SelectedDates but ' when selecting a range, the AddRange method is more ' convenient ' 'calendar.SelectedDates.Add(new DateTime(2008, 10, 14)) 'calendar.SelectedDates.Add(new DateTime(2008, 10, 15)) 'calendar.SelectedDates.Add(new DateTime(2008, 10, 16)) calendar.SelectedDates.AddRange(New DateTime(2008, 10, 14), New DateTime(2008, 10, 16), True) ' make the last day in the selection active calendar.ActiveDate = New DateTime(2008, 10, 16) AddHandler calendar.SelectedDatesChanged, AddressOf xamMonthCalendar1_SelectedDatesChanged End Sub Private Sub xamMonthCalendar1_SelectedDatesChanged(ByVal sender As Object, ByVal e As SelectedDatesChangedEventArgs) Dim sb As New Text.StringBuilder() sb.Append("Added:") For i As Integer = 0 To e.AddedDates.Count - 1 If (i > 0) Then sb.Append(", ") sb.Append(e.AddedDates(i).ToString("d")) Next i sb.AppendLine() sb.Append("Removed:") For i As Integer = 0 To e.RemovedDates.Count - 1 If (i > 0) Then sb.Append(", ") sb.Append(e.RemovedDates(i).ToString("d")) Next i sb.AppendLine() System.Diagnostics.Debug.WriteLine(sb.ToString(), "SelectedDatesChanged") End Sub
using Infragistics.Windows.Editors; using Infragistics.Windows.Editors.Events; using Infragistics.Windows.Controls; private void InitializeCalendar(XamMonthCalendar calendar) { // the selectiontype determines how dates may be selected // Range is a special type of multiple selection that ignores // the control key state and therefore doesn't allow // discontigous sections via the ui calendar.SelectionType = SelectionType.Range; // use MaxSelectedDates to restrict the number of dates // that can be selected calendar.MaxSelectedDates = 7; // you can add individual dates to the SelectedDates but // when selecting a range, the AddRange method is more // convenient // //calendar.SelectedDates.Add(new DateTime(2008, 10, 14)); //calendar.SelectedDates.Add(new DateTime(2008, 10, 15)); //calendar.SelectedDates.Add(new DateTime(2008, 10, 16)); calendar.SelectedDates.AddRange(new DateTime(2008, 10, 14), new DateTime(2008, 10, 16), true); // make the last day in the selection active calendar.ActiveDate = new DateTime(2008, 10, 16); calendar.SelectedDatesChanged += xamMonthCalendar1_SelectedDatesChanged; } void xamMonthCalendar1_SelectedDatesChanged(object sender, SelectedDatesChangedEventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append("Added:"); for(int i = 0; i < e.AddedDates.Count; i++) { if (i > 0) sb.Append(", "); sb.Append(e.AddedDates[i].ToString("d")); } sb.AppendLine(); sb.Append("Removed:"); for (int i = 0; i < e.RemovedDates.Count; i++) { if (i > 0) sb.Append(", "); sb.Append(e.RemovedDates[i].ToString("d")); } sb.AppendLine(); System.Diagnostics.Debug.WriteLine(sb.ToString(), "SelectedDatesChanged"); }