Windows Phone 7 Project

I started new CodePlex project for controls for Windows Phone 7.  One control I needed for my next application is calendar control.  I could not find one, so I started thinking about one a little while ago.  Today I published an alpha version of calendar control.  You can find it here http://wpcontrols.codeplex.com/.

Calendar control supports the following features in the initial release:

  • Next/Previous month buttons
  • Ability to provide converters to color day number or date cell background
  • Ability to select a date and apply background color
  • Data binding to SelectedDate

Calendar also supports the following events

  • MonthChanging is fired before calendar is rebuilt for the next month. Can be used to setup data for converters
  • MonthChanged is fired after calendar is rebuilt for new month/year
  • SelectionChanged is fired when a user selects a date

As part of download, you are provided with a working sample that shows how to do converters and calendar control without converters.

Here is the markup you can use in both cases:
Sample calendar control:

xmlns:wpControls="clr-namespace:WPControls;assembly=WPControls"
<wpControls:Calendar x:Name="Cal"/>

 

 


Using converters:

    <phone:PhoneApplicationPage.Resources>

        <local:BackgroundConverter x:Key="BackgroundConverter"/>

        <local:DayNumberConverter x:Key="DayNumberConverter"/>

    </phone:PhoneApplicationPage.Resources>

<wpControls:Calendar 
   
x:Name="Cal"
   BackgroundConverter="{StaticResource BackgroundConverter}"
   ForegroundConverter="{StaticResource DayNumberConverter}"
   MonthChanged="Cal_MonthChanged"
   MonthChanging="Cal_MonthChanging"
   SelectionChanged="Cal_SelectionChanged"
  
/>

Converter simply have to implement a simple interface with one method:

image

Of course, instead of hard-coded date you can drive them based off your data on the phone.  On a second note, if you need a simple, easy to use, yet powerful database for your Windows Phone 7 application, check out my other project on CodePlex: http://winphone7db.codeplex.com/

Here is what the control looks like on the phone:

CalendarControl.png