0

Is there a way to show only the month and year(i'm validating credit card expiration) without changing the source code of the toolkit when using the DatePicker?

Thiago Valle
  • 449
  • 1
  • 6
  • 20

1 Answers1

2

I know I'm a bit late now but recently I ran into the same problem. Fortunately, I have the answer to your question ;-)

Here is how we accomplish what we want: we take the DatePicker from the Windows Phone toolkit and create a modified copy of all necessary files.

Step 1: Create a modified copy of DateTimePickerPageBase and a copy of all DataSources. Simply create a file "DateTimePickerPageBase.cs" and replace its content with the one here: http://pastebin.com/wJkYrdGX.

Step 2: We have to create the page which is to displayed. Therefore, create a new "Windows Phone Page". Replace the content of the XAML-file with the one here: http://pastebin.com/Ah8CkRD9. Then, replace the content of the .xaml.cs file with the one here: http://pastebin.com/UsHnLXs7.

Step 3: If we want to use this modified DatePicker, we simply have to add the following XAML to our view:

<toolkit:DatePicker PickerPageUri="/MonthYearPicker.xaml ValueStringFormat="{}{0:y}"/>

Note: You might change the path according to the path of our xaml-file created in step 2. Note: You might change "toolkit" to the namespace-name where you included the Windows Phone toolkit.

Hope it helps ;-)

frostie
  • 101
  • 2