Reshan Kumarasingam
Reshan Kumarasingam

Reputation: 453

Get time from Xamarin Forms TimePicker

I'm developing an app in Xamarin for iOS and Android. I have a TimePicker in my XAML page. I'm invoking the picker using .Focus() method.

Since TimePicker doesn't have a DateSelected method, how do I get the value set in the popup? can someone shed some light as I couldn't figure out anywhere in their forums.

XAML

<TimePicker x:Name="datePicker" 
                WidthRequest="0" 
                HeightRequest="0"
                />

Code Behind

datePicker.Focus();

Thanks in advance.

Upvotes: 2

Views: 2048

Answers (1)

SushiHangover
SushiHangover

Reputation: 74094

var timeSpan = datePicker.Time;

Time Returns a TimeSpan. Gets or sets the displayed time. This is a bindable property.

Ref: https://developer.xamarin.com/api/type/Xamarin.Forms.TimePicker/

Upvotes: 1

Related Questions