A small demo program is included below. To reproduce the problem, select a date and click the “BlackoutDate” button. On my system I get an ArgumentOutOfRange exception.
Any suggestions on how to fix this?
XAML:
<Window x:Class="CalendarBlackoutDate.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Calendar Name="calendar"/>
<Button Name="blackoutDateButton" Content="BlackoutDate" Click="blackoutDateButton_Click"/>
</StackPanel>
</Window>
C#:
using System.Windows;
using System.Windows.Controls;
namespace CalendarBlackoutDate
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void blackoutDateButton_Click(object sender, RoutedEventArgs e)
{
calendar.BlackoutDates.Add(
new CalendarDateRange(
calendar.SelectedDate.Value));
}
}
}
Same calendar for the selected date as the blackout?? Selected date cannot be blackout date.
If one calendar