첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
다운로드

▶ MainWindow.xaml

<Window x:Class="TestProject.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="800"
    Height="600"
    Title="Calendar 클래스 사용하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <StackPanel Name="stackPanel"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Orientation="Horizontal">
        <Calendar Name="calendar1"
            Margin="5" />
    </StackPanel>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            #region 달력 1을 설정한다.

            this.calendar1.BlackoutDates.AddDatesInPast();

            #endregion
            #region 달력 2를 설정한다.

            Calendar calendar2 = new Calendar();

            calendar2.Margin           = new Thickness(5);
            calendar2.DisplayDateStart = new DateTime(2009, 1, 10);
            calendar2.DisplayDateEnd   = new DateTime(2009, 4, 18);
            calendar2.DisplayDate      = new DateTime(2009, 3, 15);
            calendar2.SelectedDate     = new DateTime(2009, 2, 15);

            this.stackPanel.Children.Add(calendar2);

            #endregion
            #region 달력 3을 설정한다.

            Calendar calendar3 = new Calendar();

            calendar3.Margin             = new Thickness(5);
            calendar3.IsTodayHighlighted = false;
            calendar3.DisplayDate        = new DateTime(2009, 1, 1);
            calendar3.DisplayDateEnd     = new DateTime(2009, 1, 31);
            calendar3.SelectionMode      = CalendarSelectionMode.MultipleRange;
          
            calendar3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 2 ), new DateTime(2009, 1, 4 )));
            calendar3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 9                            )));
            calendar3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 16                           )));
            calendar3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 23), new DateTime(2009, 1, 25)));
            calendar3.BlackoutDates.Add(new CalendarDateRange(new DateTime(2009, 1, 30                           )));

            calendar3.SelectedDates.Add(new DateTime(2009, 1, 5));

            calendar3.SelectedDates.AddRange(new DateTime(2009, 1, 12), new DateTime(2009, 1, 15));

            calendar3.SelectedDates.Add(new DateTime(2009, 1, 27));

            this.stackPanel.Children.Add(calendar3);

            #endregion
            #region 달력 4를 설정한다.

            Calendar calendar4 = new Calendar();

            calendar4.Margin      = new Thickness(5);
            calendar4.DisplayMode = CalendarMode.Year;

            calendar4.DisplayModeChanged += calendar4_DisplayModeChanged;

            this.stackPanel.Children.Add(calendar4);

            #endregion
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 달력 4 표시 모드 변경시 처리하기 - calendar4_DisplayModeChanged(sender, e)

        /// <summary>
        /// 달력 4 표시 모드 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void calendar4_DisplayModeChanged(object sender, CalendarModeChangedEventArgs e)
        {
            Calendar calendar = sender as Calendar;

            calendar.DisplayMode = CalendarMode.Year;
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요