Lucidity
Lucidity

Reputation: 555

Using a DatePicker without TextBox (Silverlight Toolkit) WP7

I am developing an app for Windows Phone 7.8 (probably WP8 at a later date) that needs the user to enter a date. I am currently using the DatePicker control from the Silverlight Toolkit as I like the visual style of it.

The DatePicker control, when placed on the page, is shown as a TextBox that when clicked opens the DatePicker.

Is there anyway to not have the TextBox included as I do not need and it is cluttering up my form. Maybe a way to open the DatePicker through code rather than trough the OnClick event?

Any help is appreciated :)

Upvotes: 0

Views: 788

Answers (4)

user1264392
user1264392

Reputation: 13

What is the event that should trigger the opening of the datepicker page? Is it a click or tap on a button, an image or what? If it is any of these, you could place a DatePicker in xaml over that control so that they overlap (placing them in a grid's same row, same column). Set the Opacity of the DatePicker to 0. Then the user will not see the DatePicker's TextBox, just the control below it. However, when the user clicks on that control (button, image, etc), he or she will in fact click on the invisible DatePicker and then the datepicker page will open up.

Upvotes: 0

Silver Solver
Silver Solver

Reputation: 2320

You can simply edit the Control Template of the DatePicker to change the way it looks.

VS 2012 can do this by default (right click and edit template), else you will need to edit the template using Expression Blend.

In particular, the Control Template consists of a Button (among other things):

<Button x:Name="DateTimeButton"
        Content="{TemplateBinding ValueString}"
        ...

The Buttons Content property is bound to ValueString. If you remove this Binding (for example) you will be left with a blank button. You could put anything you like in the content of the button...


These links should help you get started with using Blend:

Styling a control that supports templates

Create or modify a template

The guides on Project Rosetta are nice too.

Upvotes: 1

Viktor
Viktor

Reputation: 26

I think that you can instantiate the DatePickerPage object and navigate to it. As I understand it has a Value property (coming from the IDateTimePickerPage interface) which you can set and read.

I cannot test it at today but I will definitely try it tomorrow and let you know what I found. Meantime you can go to the http://silverlight.codeplex.com/ page and check the source of the Toolkit.

Upvotes: 0

Quan Vo
Quan Vo

Reputation: 1799

may be, you can create the DatePicker and hiden it. when you click item (item which you want to use), you change focus to DatePicker.

Upvotes: 0

Related Questions