TimePicker.SelectedTimeChanged 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生於 SelectedTime
屬性的值變更時。
// 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" />
事件類型
範例
如需使用 和 來更新單DateTime
一值的範例,請參閱行事曆、日期和時間控制件 - 同時使用日期選擇器和時間選擇器。TimePicker
DatePicker
<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);
}
}