Version

SelectedDatesChanged Event

Occurs after the SelectedDates has been changed.
Syntax
'Declaration
 
Public Event SelectedDatesChanged As EventHandler(Of SelectedDatesChangedEventArgs)
public event EventHandler<SelectedDatesChangedEventArgs> SelectedDatesChanged
Event Data

The event handler receives an argument of type SelectedDatesChangedEventArgs containing data related to this event. The following SelectedDatesChangedEventArgs properties provide information specific to this event.

PropertyDescription
AddedDates Returns a list of the dates that were selected.
Handled (Inherited from System.Windows.RoutedEventArgs)Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
OriginalSource (Inherited from System.Windows.RoutedEventArgs)Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
RemovedDates Returns a list of the dates that were unselected.
RoutedEvent (Inherited from System.Windows.RoutedEventArgs)Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source (Inherited from System.Windows.RoutedEventArgs)Gets or sets a reference to the object that raised the event.
Example
The following sample demonstrates some of the properties and events related to selecting dates within the XamMonthCalendar.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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");
        }
<UserControl x:Class="Xaml.UserControl1"
    
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
xmlns:sys="clr-namespace:System;assembly=mscorlib"
    
xmlns:igEditors="http://infragistics.com/Editors"
    
xmlns:igThemes="http://infragistics.com/Themes">
    
<igEditors:XamMonthCalendar
        
x:Name="xamMonthCalendar1"
        
ActiveDate="10/16/2008"
        
SelectionType="Range"
        
MaxSelectedDates="7"
        
SelectedDatesChanged="xamMonthCalendar1_SelectedDatesChanged"
        
>
        
<igEditors:XamMonthCalendar.SelectedDates>
            
<sys:DateTime>10/14/2008</sys:DateTime>
            
<sys:DateTime>10/15/2008</sys:DateTime>
            
<sys:DateTime>10/16/2008</sys:DateTime>
        
</igEditors:XamMonthCalendar.SelectedDates>
    
</igEditors:XamMonthCalendar>
</UserControl>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also