如何在Calendar BlackoutDates上检测MouseDoubleClick?

时间:2017-07-20 14:47:55

标签: .net wpf calendar double-click

在我的WPF / C#应用中,我有一个Calendar控件,其中设置了BlackoutDates个范围。我还想处理MouseDoubleClick个事件,但是我无法确定如何确定用户在中断日期双击 - 在这种情况下返回到事件处理程序的日期是最近选择的有效(即非禁止日期)日期。我怎么能忽视"双击这些BlackoutDates

编辑:
XAML:

<Calendar MouseDoubleClick="Calendar_MouseDoubleClick"/>

代码背后:

private void Calendar_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    if (myCalendarBlackoutDatesCollection.Contains(/* what goes here? */))
    {
        return;  // ignore doubleclick
    }
    // execution continues here
}

1 个答案:

答案 0 :(得分:2)

您可以通过定义MouseDoubleClick来处理每个人CalendarDayButton的{​​{1}}:

CalendarDayButtonStyle
<Calendar x:Name="cal">
    <Calendar.CalendarDayButtonStyle>
        <Style TargetType="CalendarDayButton">
            <EventSetter Event="MouseDoubleClick" Handler="cal_MouseDoubleClick" />
        </Style>
    </Calendar.CalendarDayButtonStyle>
</Calendar>