Events
The RadCalendar exposes three events that can be handled: SelectionChanged, DisplayDateChanged and DisplayModeChanged. The events are routed events but can also be handled like normal events:
public partial class Default_Cs : UserControl
{
public Default_Cs ()
{
this.InitializeComponent();
calendar.SelectionChanged += calendar_SelectionChanged;
calendar.SelectionChanged +=calendar_SelectionChanged;
}
void calendar_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
message.Text = String.Format("{0} dates have been selected.", calendar.SelectedDates.Count);
}
}
<StackPanel>
<telerik:RadCalendar x:Name="calendar" SelectionMode="Extended"/>
<TextBlock x:Name="message" />
</StackPanel>
This can be very helpful when notification is needed from controls that are part of data templates and as such are nor easily accessible.
The following example shows how to sign up for the SelectionChanged event at a parent panel of the RadCalendar.
public Page()
{
InitializeComponent();
//Sign up for the event:
this.LayoutRoot.AddHandler(RadCalendar.SelectionChangedEvent, new SelectionChangedEventHandler(OnCalendarSelectionChanged));
}
private void OnCalendarSelectionChanged(object sender, SelectionChangedEventArgs e)
{
}