CalendarMode 枚举

定义

指定 Calendar 是否显示月份、年份或十年期。Specifies whether a Calendar displays a month, year, or decade.

public enum class CalendarMode
public enum CalendarMode
type CalendarMode = 
Public Enum CalendarMode
继承
CalendarMode

字段

Decade 2

Calendar 一次显示一个十年。The Calendar displays a decade at a time.

Month 0

Calendar 一次显示一个月。The Calendar displays a month at a time.

Year 1

Calendar 一次显示一年。The Calendar displays a year at a time.

示例

下面的示例创建一个日历, 其中显示一年中的月份并处理DisplayModeChanged该事件, 以便当用户单击一个月或一年时, 日历不会更改其。 DisplayModeThe following example creates a calendar that displays the months in a year and handles the DisplayModeChanged event so that when the user clicks on a month or the year, the calendar does not change its DisplayMode.

Calendar yearCalendar = new Calendar();
yearCalendar.DisplayMode = CalendarMode.Year;
yearCalendar.DisplayModeChanged +=
    new EventHandler<CalendarModeChangedEventArgs>(Calendar_DisplayModeChanged);

// root is a Panel that is defined elswhere.
root.Children.Add(yearCalendar);
Dim yearCalendar As New Calendar()
yearCalendar.DisplayMode = CalendarMode.Year
AddHandler yearCalendar.DisplayModeChanged, AddressOf Calendar_DisplayModeChanged

' root is a Panel that is defined elswhere. 
root.Children.Add(yearCalendar)
<Calendar DisplayMode="Year" DisplayModeChanged="Calendar_DisplayModeChanged" />
private void Calendar_DisplayModeChanged(object sender,
                                         CalendarModeChangedEventArgs e)
{
    Calendar calObj = sender as Calendar;

    calObj.DisplayMode = CalendarMode.Year;
}
    Private Sub Calendar_DisplayModeChanged(ByVal sender As Object, ByVal e As CalendarModeChangedEventArgs)
        Dim calObj As Calendar = TryCast(sender, Calendar)

        calObj.DisplayMode = CalendarMode.Year
    End Sub

    Private Sub calendar1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Dim cal = TryCast(sender, Calendar)
        cal.BlackoutDates.AddDatesInPast()
    End Sub

End Class

注解

Calendar次可以显示月、年或十年。A Calendar can display a month, a year, or a decade at a time. 下表列出了用户如何导航到每个模式。The following table lists how the user navigates to each mode.

DisplayModeDisplayMode 操作Action
月份Month 若要导航到 Year 模式, 请单击月份标题。To navigate to Year mode, click the month heading.
Year 若要导航到十年模式, 请单击年份标题。To navigate to Decade mode, click the year heading. 若要导航到月模式, 请单击显示的月份之一。To navigate to Month mode, click one of the displayed months.
十年Decade 若要导航到 Year 模式, 请单击显示的年份之一。To navigate to Year mode, click one of the displayed years.

适用于