Brian Var
Brian Var

Reputation: 6227

How to add a custom time picker in a Windows Phone 8.1 app?

I have implemented time input as a length of time in my application using a textbox and parsing the string to a TimeSpan object.

//Assign text box string value to a time span variable.
TimeSpan workTm = TimeSpan.ParseExact(wrkString, @"hh\ \:\ mm\ \:\ ss\ \:\ fff", CultureInfo.InvariantCulture);

But I'm wondering how I can add a time picker control like the below image to the application. I don't see any available control in the toolbox.

Is the any custom control that I could use and how is it implemented?

time picker win phone 8.1 app

Upvotes: 1

Views: 1734

Answers (1)

Igor Ralic
Igor Ralic

Reputation: 15006

If you're making a Silverlight Windows Phone 8.1 app, you need to use the TimePicker control from Silverlight Windows Phone toolkit.

Read more about TimePicker and DatePicker controls from Silverlight Windows Phone toolkit here.

If you're making a WinRT Windows Phone 8.1 app, there's a TimePicker control included in the SDK. (yaay!)

Comes down to using it like this: (Silverlight)

<toolkit:TimePicker Value="{Binding Date}” />

or: (WinRT)

<TimePicker Time="{Binding Time}"/>

More info about migrating from one to another which includes certain subtle differences can be found on Shawn's blog.

Upvotes: 2

Related Questions