WP8 calendar (including lunar) APP
WP8 calendar (including lunar) APP UI XAML (partial)
<phone:phoneapplicationpage xmlns:customcontrol= "Clr-namespace:calendarapp.customcontrol" xmlns:Controls= " Clr-namespace:microsoft.phone.controls;assembly=microsoft.phone.controls.toolkit "x:Class=" CalendarApp.MainPage "Xmlns=" http://schemas.microsoft.com/winfx/2006/xaml/presentation "xmlns:x=" http://schemas.microsoft.com/winfx/ 2006/xaml "xmlns:phone=" Clr-namespace:microsoft.phone.controls;assembly=microsoft.phone "xmlns:shell=" Clr-namespace:microsoft.phone.shell;assembly=microsoft.phone "xmlns:d=" http://schemas.microsoft.com/expression/ blend/2008 "xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/2006 "mc:ignorable=" D "fontfamily=" { StaticResource Phonefontfamilynormal} "fontsize=" {StaticResource phonefontsizenormal} "foreground=" {StaticResource Phoneforegroundbrush} "supportedorientations=" Portrait "orientation=" Portrait "shell:systemtray.isvisible=" True " loaded= "phoneapplicationpage_loaded" > <grid x:name= "LayoutRoot "background=" Transparent "> <stackpanel x:name=" Spcalendar "margin=" 0 "orientation=" Vertical "> <textblock name= "Txthead" text= "" style= "{StaticResource titlecss}"/> <!--calendar Head-- <stackpanel orientation= "Vertical" > <!--Calendar button--<stackpanel orientatio n= "Horizontal" horizontalalignment= "Center" > <image source= "/images/left.png" manipulationstarted = "image_manipulationstarted"/> <stackpanel orientation= "Horizontal" manipulationstarted= "StackPa Nel_manipulationstarted "> <textblock name=" txtyear "text=" style= "{StaticResource CHEADC SS} "width="/> <textblock text= "year" style= "{StaticResource cheadcss}"/> <textblock name= "Txtmonth" text= "style=" {StaticResource cheadcss} "width="/> <textblock text= "Month" Style= "{StaticResource cheadcss}"/> </StackPanel> <image source= "/imag Es/right.png "manipulationstarted=" image_manipulationstarted "/> </StackPanel> < !--Calendar Title--<stackpanel orientation= "Horizontal" > <textblock text= "Day" Style = "{StaticResource ctitlergreen}"/> <textblock text= "One" style= "{StaticResource ctitlecss}"/> <textblock text= "Two" style= "{StaticResource ctitlecss}"/> <textblock text= " Three "style=" {StaticResource ctitlecss} "/> <textblock text=" Four "style=" {StaticResource ctitlecss} "/ > <textblock text= "Five" style= "{StaticResource ctitlecss}"/> <textblock T Ext= "Six" style= "{StaticResource ctitlergreen}"/> </StackPanel> </StackPanel> <!--calendar content--> <grid name= "Gcalendar" background= "Gray" width= "480" height= "615" > <Grid.RowDefinitions> <rowdefinition height= "*"/> <rowdefinition height= "*"/> <rowdefinition height= "*"/> <rowdefinition height= "*"/> <rowdefinit Ion height= "*"/> <rowdefinition height= "*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <columndefinition width= "*"/> < ColumnDefinition width= "*"/> <columndefinition width= "*"/> <columndefi Nition width= "*"/> <columndefinition width= "*"/> <columndefinition Wid Th= "*"/> <columndefinition width= "*"/> </Grid.ColumnDefinitions> </Grid> </StackPanel> </Grid></phone:PhoneApplicationPage>
Background CS Reference Code (part):
Using system;using system.collections.generic;using system.linq;using system.net;using System.Windows;using System.windows.controls;using system.windows.navigation;using microsoft.phone.controls;using Microsoft.phone.shell;using calendarapp.resources;using system.collections.objectmodel;using Model;using Chinesecalendar;using calendarapp.pagecode;using calendarapp.customcontrol;using Microsoft.phone.controls.primitives;namespace calendarapp{public partial class Mainpage:phoneapplicationpage { #region Global variables///<summary>//Bgdateweek The first day of the month///</summary> int Bgdatew EEK = new int (); <summary>//observablecollection<calendarmodel> MyCalendar//</summary> Obs ervablecollection<calendarmodel> MyCalendar = new Observablecollection<calendarmodel> {}; #endregion public MainPage () {InitializeComponent (); } private void PhoneApplicationpage_loaded (object sender, RoutedEventArgs e) {//Current date data DateTime dt = datetime.no W if (this. NavigationContext.QueryString.Count > 0 && this. navigationcontext.querystring["T"]! = NULL) if (! Datetime.tryparse (this. navigationcontext.querystring["T"]. ToString (), out dt)) dt = DateTime.Now; This.txtYear.Text = dt. ToString ("yyyy"); This.txtMonth.Text = dt. ToString ("MM"); Load Date data getmonthdate (DT) for the current month. ToString ("Yyyy-mm-dd")); #region get the calendar data at the specified time///<summary>///To get calendar data at a specified time///</summary>//&L T;param name= "Dtmonth" > Time yyyy-mm</param> public void getmonthdate (String dtmonth) {//Initial Start parameter DateTime dt = DateTime.Now; if (! Datetime.tryparse (Dtmonth, out dt)) dt = DateTime.Now; Gets the first day, last day of the selected date. As well as the first day of the week several DateTime bgdate, Eddate, gldate; Bgdate = new DateTime (dt. Year, dt. Month, 1); Eddate = bgdate.addmonths (1). AddDays (-1); Getweekindex (BGDate.DayOfWeek.ToString ()); Define your own control customcontrol.customdate cd = null; Customcontrol.customdategreen cdgreen = null; Initialize variable Calendarmodel item = NULL; Empty this.gCalendar.Children.Clear (); The loop joins the data int row = 0, col = 0; for (int i = 0, Len = (eddate-bgdate). Days; I <= Len; i++) {//Set row and column if (i = = 0) col = bgdateweek; else col++; if (Col > 6) {col = 0; row++; } gldate = Bgdate.adddays (i); item = new Calendarmodel () {glday = gldate.tostring ("dd"), gldate = Gldate.tostring ("Yyyy-mm-dd"), NLday = Chinesecalendardate.getchinesedate (gldate), nldate = Chinesecalendardate.getchinesedatetime (GLDa TE)}; Annual Information String year = Item. Nldate.substring (0, item. Nldate.indexof ("Year") + 1); This.txtHead.Text = "Lunar Calendar" + year; Bind data if (col = = 0 | | col = = 6) {Cdgreen = new Customdategreen (); Cdgreen.datacontext = Item; Grid.setcolumn (Cdgreen, col); Grid.setrow (Cdgreen, Row); THIS.GCALENDAR.CHILDREN.ADD (Cdgreen); } else {cd = new customdate (); Cd. DataContext = Item; Grid.setcolumn (CD, col); Grid.setrow (CD, row); THIS.GCALENDAR.CHILDREN.ADD (CD); #endregion #region Get the week index//<SUmmary>///Get week index//</summary>//<param name= "Week" ></param> private void Getweekindex (String week) {switch (week) {case "Monday"://Mon Bgdateweek = 1; Break Case "Tuesday"://Tuesday bgdateweek = 2; Break Case "Wednesday"://Wednesday bgdateweek = 3; Break Case "Thursday"://Thursday bgdateweek = 4; Break Case "Friday"://Friday bgdateweek = 5; Break Case "Saturday"://Saturday Bgdateweek = 6; Break Case "Sunday"://weekend Bgdateweek = 0; Break }} #endregion #region time Select//<summary>//Time Select//</summary>//<param name= "sender" ></param>///<param name= "E" ></param> p rivate void Image_manipulationstarted (object sender, System.Windows.Input.ManipulationStartedEventArgs e) { Image image = (image) sender; if (image! = null) {int y = Int. Parse (This.txtYear.Text); int m = Int. Parse (This.txtMonth.Text); if ((System.Windows.Media.Imaging.BitmapImage) (image. Source)). Urisource.tostring (). Contains ("Left.png")) {//Time decrement if (m-1 <= 0) {//Previous year This.txtMonth.Text = "12"; This.txtYear.Text = (y-1). ToString (). Trim (); } else {//year, month descending m--; if (M = = 0) m = 1; This.txtmoNth. Text = M >= 10? M.tostring (): "0" + m.tostring (); }} else {//time increment if (M + 1 > 12) {//After year this.txtMonth.Text = "01"; This.txtYear.Text = (y + 1). ToString (). Trim (); } else {//year, month increment m++; This.txtMonth.Text = M >= 10? M.tostring (): "0" + m.tostring (); }}//Get new Time getnewdate (); }} #endregion #region Select//<summary>///</summary> ; <param name= "Sender" ></param>//<param name= "E" ></param> private void Stackpan El_manipulationstarted (object sender, SYSTEM.WINDOWS.INPUT.MAnipulationstartedeventargs e) {String time = This.txtYear.Text + "-" + this.txtMonth.Text; This. Navigationservice.navigate (The New Uri ("/customcontrol/customdatepicker.xaml")?T= "+ Time, urikind.relative)); #endregion #region Get new Time///<summary>//Get new Time///</summary> PU Blic void Getnewdate () {//Current date data datetime dt = DateTime.Parse (This.txtYear.Text.Trim () + "-" + This.txtMonth.Text.Trim ()); This.txtYear.Text = dt. ToString ("yyyy"); This.txtMonth.Text = dt. ToString ("MM"); Load Date data getmonthdate (DT) for the current month. ToString ("Yyyy-mm-dd")); } #endregion}}
Note: Due to the inability to use the Chineselunisolarcalendar class in this instance, the exact data of the Chinese lunar calendar cannot be obtained
The lunar data in the case is incorrect. If there are capable to help solve.
will be greatly appreciated!
Define a class to get Chinese lunar date data by Gregorian calendar: http://blog.csdn.net/yimiyuangguang/article/details/24301933
Example Download:
http://pan.baidu.com/s/1gd5UU5d
:
WP8 calendar (including lunar) APP