WP7 MonthYear Picker

For credit card expiry dates I needed to mod the Microsoft.Phone.Controls.DatePicker to only ask for Month and Year.
 
This was surprisingly convoluted but thanks for reflector, achievable. The xaml for the existing date picker is a resource in the dll but you do have to do a fair amount of work to keep it happy that it doesn’t have a day part anymore.
 
Seems to work and we’re on track for submitting the app tomorrow! 🙂

4 thoughts on “WP7 MonthYear Picker

  1. Indeed I am. You can override the xaml page used for the picker by setting PickerPageUri, e.g.


    <toolkit:DatePicker PickerPageUri="/Views/MonthYearPicker.xaml"
    Value="{Binding ExpiryDateSelectorValue, Mode=TwoWay}"
    ValueStringFormat="{}{0:MM/yyyy}"
    Margin="-10,0,0,0" />

    Then provide a MonthYearPicker.xaml page which has some code to override the different datasources (such as YearDataSource etc.). You can use reflector to extract the existing DateTimePicker.xaml.

Leave a reply to SRansom Cancel reply