.Net Project/SilverLight 3.0

53장 Calendar 컨트롤

Magic_kit 2009. 12. 2. 16:59
반응형
  Calendar 컨트롤
 - 달력을 화면에 표시하고 사용자가 날짜를 선택할 수 있는 컨트롤
 - Calendar 컨트롤은 다음과 같이 주요 속성에 에 따라 지정하여 사용 가능

  Calendar.Xaml





<UserControl xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="RiaCalendar.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>

            <my:Calendar x:Name="cal" Background="Bisque"

                         FontFamily="Arial"

                         FontSize="20"

                         BorderBrush="Green"

                         BorderThickness="5">       

            </my:Calendar> 

            <TextBlock x:Name="lblDisplay" Width="150" Height="50"></TextBlock>

        </StackPanel>       

    </Grid>

</UserControl> 

  Calendar.Cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaCalendar

{

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

 

            this.cal.SelectedDatesChanged += new
               EventHandler
<SelectionChangedEventArgs>(cal_SelectedDatesChanged);

        }

 

        void cal_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)

        {

            //lblDisplay.Text = cal.SelectedDate.ToString();

            lblDisplay.Text = String.Format
                              (
"{0:yyyy-MM-dd hh:mm:ss}", cal.SelectedDate);

        }

    }

} 





반응형