첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

■ Calendar 클래스 사용하기

------------------------------------------------------------------------------------------------------------------------


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>

 

 

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 , ,

댓글을 달아 주세요