开发者

DatePicker control WP7

I am using the DatePicker control from WP7 control toolkit in my app for the user to enter in an expiration date. One of the scenarios is that the record doesn't have an expiration date. How can I use the control such that by default, there is no date specified in the control and the user can select a different date?

Also,开发者_开发问答 if I user sets an expiration date but letter wants to clear it, I need to enable that as well.

Pratik


  1. For the default value to be blank, in the XAML

     <toolkit:DatePicker x:Name="dpComp" Value="" Width="220" Hold="dpComp_Hold"/>
    
  2. If you would like to allow a user to clear the value of datepicker then you can do this in the code

    private void dpComp_Hold(object sender, System.Windows.Input.GestureEventArgs e)
    {
        //Let user to clear the value.
        ((DatePicker)sender).Value = null;
    


The DatePicker control doesn't support the concept of no date selected.
The DatePicker will default to the current date if none is selected on the assumption that this will be the most useful to the user. Forcing the user to select values which you could provide a likely default value for means you're making the user do more work than they should have to and you are therefore wasting their time.

If no expiry date is valid, leave this field blank by default.

With regard to clearing an entered date, add a separate option to do this. Either a button or menu option.


I would look at the .api for customization of the DatePicker Control: http://windowsphonegeek.com/articles/wp7-datepicker-and-timepicker-in-depth--api-and-customization

I don't know of anyway to do what you are looking for (however I might want to know in the future). The link above seems to suggest you can create your own custom page and you can then maybe work out a way to return what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜