■ CalendarView 엘리먼트를 사용하는 방법을 보여준다.
▶ Language.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
namespace TestProject { /// <summary> /// 언어 /// </summary> public class Language { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 명칭 - Name /// <summary> /// 명칭 /// </summary> public string Name { get; set; } #endregion #region 코드 - Code /// <summary> /// 코드 /// </summary> public string Code { get; set; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - Language(name, code) /// <summary> /// 생성자 /// </summary> /// <param name="name">명칭</param> /// <param name="code">코드</param> public Language(string name, string code) { Name = name; Code = code; } #endregion } } |
▶ LanguageList.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
using System.Collections.Generic; namespace TestProject { /// <summary> /// 언어 리스트 /// </summary> public class LanguageList : List<Language> { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - LanguageList() /// <summary> /// 생성자 /// </summary> public LanguageList() { Add(new Language("English" , "en" )); Add(new Language("Arabic" , "ar" )); Add(new Language("Afrikaans" , "af" )); Add(new Language("Albanian" , "sq" )); Add(new Language("Amharic" , "am" )); Add(new Language("Armenian" , "hy" )); Add(new Language("Assamese" , "as" )); Add(new Language("Azerbaijani" , "az" )); Add(new Language("Basque " , "eu" )); Add(new Language("Belarusian" , "be" )); Add(new Language("Bangla" , "bn" )); Add(new Language("Bosnian" , "bs" )); Add(new Language("Bulgarian" , "bg" )); Add(new Language("Catalan" , "ca" )); Add(new Language("Chinese (Simplified)", "zh" )); Add(new Language("Croatian" , "hr" )); Add(new Language("Czech" , "cs" )); Add(new Language("Danish" , "da" )); Add(new Language("Dari" , "prs")); Add(new Language("Dutch" , "nl" )); Add(new Language("Estonian" , "et" )); Add(new Language("Filipino" , "fil")); Add(new Language("Finnish" , "fi" )); Add(new Language("French " , "fr" )); Add(new Language("Galician" , "gl" )); Add(new Language("Georgian" , "ka" )); Add(new Language("German" , "de" )); Add(new Language("Greek" , "el" )); Add(new Language("Gujarati" , "gu" )); Add(new Language("Hausa" , "ha" )); Add(new Language("Hebrew" , "he" )); Add(new Language("Hindi" , "hi" )); Add(new Language("Hungarian" , "hu" )); Add(new Language("Icelandic" , "is" )); Add(new Language("Indonesian" , "id" )); Add(new Language("Irish" , "ga" )); Add(new Language("isiXhosa" , "xh" )); Add(new Language("isiZulu" , "zu" )); Add(new Language("Italian" , "it" )); Add(new Language("Japanese " , "ja" )); Add(new Language("Kannada" , "kn" )); Add(new Language("Kazakh" , "kk" )); Add(new Language("Khmer" , "km" )); Add(new Language("Kinyarwanda" , "rw" )); Add(new Language("KiSwahili" , "sw" )); Add(new Language("Konkani" , "kok")); Add(new Language("Korean" , "ko" )); Add(new Language("Lao" , "lo" )); Add(new Language("Latvian" , "lv" )); Add(new Language("Lithuanian" , "lt" )); Add(new Language("Luxembourgish" , "lb" )); Add(new Language("Macedonian" , "mk" )); Add(new Language("Malay" , "ms" )); Add(new Language("Malayalam" , "ml" )); Add(new Language("Maltese" , "mt" )); Add(new Language("Maori " , "mi" )); Add(new Language("Marathi" , "mr" )); Add(new Language("Nepali" , "ne" )); Add(new Language("Norwegian" , "nb" )); Add(new Language("Odia" , "or" )); Add(new Language("Persian" , "fa" )); Add(new Language("Polish" , "pl" )); Add(new Language("Portuguese" , "pt" )); Add(new Language("Punjabi" , "pa" )); Add(new Language("Quechua" , "quz")); Add(new Language("Romanian" , "ro" )); Add(new Language("Russian" , "ru" )); Add(new Language("Serbian (Latin)" , "sr" )); Add(new Language("Sesotho sa Leboa" , "nso")); Add(new Language("Setswana" , "tn" )); Add(new Language("Sinhala" , "si" )); Add(new Language("Slovak " , "sk" )); Add(new Language("Slovenian" , "sl" )); Add(new Language("Spanish" , "es" )); Add(new Language("Swedish" , "sv" )); Add(new Language("Tamil" , "ta" )); Add(new Language("Telugu" , "te" )); Add(new Language("Thai" , "th" )); Add(new Language("Tigrinya" , "ti" )); Add(new Language("Turkish" , "tr" )); Add(new Language("Ukrainian" , "uk" )); Add(new Language("Urdu" , "ur" )); Add(new Language("Uzbek (Latin)" , "uz" )); Add(new Language("Vietnamese" , "vi" )); Add(new Language("Welsh" , "cy" )); Add(new Language("Wolof" , "wo" )); } #endregion } } |
▶ MainPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<Page x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <Grid HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="50" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <CalendarView Name="calendarView" Grid.Column="0" IsGroupLabelVisible="{x:Bind isGroupLabelVisibleCheckBox.IsChecked.Value, Mode=OneWay}" IsOutOfScopeEnabled="{x:Bind isOutOfScopeEnabledCheckBox.IsChecked.Value, Mode=OneWay}" CalendarIdentifier="{x:Bind calendarIdentifierComboBox.SelectedValue, Mode=OneWay}" SelectionMode="Single" /> <StackPanel Grid.Column="2"> <CheckBox Name="isGroupLabelVisibleCheckBox" Content="IsGroupLabelVisible 속성" IsChecked="True" /> <CheckBox Name="isOutOfScopeEnabledCheckBox" Content="IsOutOfScopeEnabled 속성" IsChecked="True" /> <ComboBox Margin="0 10 0 0" SelectedValue="Single" Header="SelectionMode 속성" SelectionChanged="selectionModeComboBox_SelectionChanged"> <x:String>None</x:String> <x:String>Single</x:String> <x:String>Multiple</x:String> </ComboBox> <ComboBox x:Name="calendarIdentifierComboBox" Margin="0 10 0 0" Width="220" Header="CalendarIdentifier 속성" /> <ComboBox Name="calendarLanguageComboBox" Margin="0 10 0 0" Width="220" DisplayMemberPath="Name" SelectedValuePath="Code" SelectedIndex="0" Header="Language 속성" SelectionChanged="calendarLanguageComboBox_SelectionChanged" /> </StackPanel> </Grid> </Grid> </Page> |
▶ MainPage.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
using System; using System.Collections.Generic; using Windows.Foundation; using Windows.Globalization; using Windows.Graphics.Display; using Windows.UI.ViewManagement; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 메인 페이지 /// </summary> public sealed partial class MainPage : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainPage() /// <summary> /// 생성자 /// </summary> public MainPage() { InitializeComponent(); #region 윈도우 크기를 설정한다. double width = 800d; double height = 600d; double dpi = (double)DisplayInformation.GetForCurrentView().LogicalDpi; ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; Size windowSize = new Size(width * 96d / dpi, height * 96d / dpi); ApplicationView.PreferredLaunchViewSize = windowSize; Window.Current.Activate(); ApplicationView.GetForCurrentView().TryResizeView(windowSize); #endregion #region 윈도우 제목을 설정한다. ApplicationView.GetForCurrentView().Title = "CalendarView 엘리먼트 사용하기"; #endregion List<string> calendarIdentifierList = new List<string>() { CalendarIdentifiers.Gregorian, CalendarIdentifiers.Hebrew, CalendarIdentifiers.Hijri, CalendarIdentifiers.Japanese, CalendarIdentifiers.Julian, CalendarIdentifiers.Korean, CalendarIdentifiers.Persian, CalendarIdentifiers.Taiwan, CalendarIdentifiers.Thai, CalendarIdentifiers.UmAlQura, }; this.calendarIdentifierComboBox.ItemsSource = calendarIdentifierList; this.calendarIdentifierComboBox.SelectedItem = CalendarIdentifiers.Gregorian; this.calendarLanguageComboBox.ItemsSource = new LanguageList(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 선택 모드 콤보 박스 선택 변경시 처리하기 - selectionModeComboBox_SelectionChanged(sender, e) /// <summary> /// 선택 모드 콤보 박스 선택 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void selectionModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if(Enum.TryParse<CalendarViewSelectionMode>((sender as ComboBox).SelectedItem.ToString(), out CalendarViewSelectionMode selectionMode)) { this.calendarView.SelectionMode = selectionMode; } } #endregion #region 달력 언어 콤보 박스 선택 변경시 처리하기 - calendarLanguageComboBox_SelectionChanged(sender, e) /// <summary> /// 달력 언어 콤보 박스 선택 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void calendarLanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { string language = this.calendarLanguageComboBox.SelectedValue.ToString(); if(Windows.Globalization.Language.IsWellFormed("ko")) { this.calendarView.Language = language; } } #endregion } } |