TimePicker.SelectedTimeChanged Kejadian
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Terjadi ketika nilai SelectedTime
properti diubah.
// Register
event_token SelectedTimeChanged(TypedEventHandler<TimePicker, TimePickerSelectedValueChangedEventArgs const&> const& handler) const;
// Revoke with event_token
void SelectedTimeChanged(event_token const* cookie) const;
// Revoke with event_revoker
TimePicker::SelectedTimeChanged_revoker SelectedTimeChanged(auto_revoke_t, TypedEventHandler<TimePicker, TimePickerSelectedValueChangedEventArgs const&> const& handler) const;
public event TypedEventHandler<TimePicker,TimePickerSelectedValueChangedEventArgs> SelectedTimeChanged;
function onSelectedTimeChanged(eventArgs) { /* Your code */ }
timePicker.addEventListener("selectedtimechanged", onSelectedTimeChanged);
timePicker.removeEventListener("selectedtimechanged", onSelectedTimeChanged);
- or -
timePicker.onselectedtimechanged = onSelectedTimeChanged;
Public Custom Event SelectedTimeChanged As TypedEventHandler(Of TimePicker, TimePickerSelectedValueChangedEventArgs)
<TimePicker SelectedTimeChanged="eventhandler" />
Jenis Acara
Contoh
Untuk contoh penggunaan DatePicker
dan bersama-sama untuk memperbarui satu DateTime
nilai, lihat Kontrol kalender, tanggal, dan waktu - Gunakan pemilih tanggal dan pemilih waktu bersama-samaTimePicker
.
<TimePicker SelectedTimeChanged="TimePicker_SelectedTimeChanged"/>
<TextBlock x:Name="resultText"/>
private void TimePicker_SelectedTimeChanged(TimePicker sender, TimePickerSelectedValueChangedEventArgs args)
{
DateTime myTime = DateTime.Today + (TimeSpan)args.NewTime;
if (DateTime.Now >= myTime)
{
resultText.Text = "Your selected time has already past.";
}
else
{
string hrs = (myTime - DateTime.Now).Hours.ToString();
string mins = (myTime - DateTime.Now).Minutes.ToString();
resultText.Text = string.Format("Your selected time is {0} hours, {1} minutes from now.", hrs, mins);
}
}