다음을 통해 공유


TimePicker.SelectedTimeChanged 이벤트

정의

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" />

이벤트 유형

Windows 요구 사항

디바이스 패밀리
Windows 10, version 1809 (10.0.17763.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v7.0에서 도입되었습니다.)

예제

DatePickerTimePicker를 함께 사용하여 단일 DateTime 값을 업데이트하는 예제는 달력, 날짜 및 시간 컨트롤 - 날짜 선택기와 시간 선택기를 함께 사용을 참조하세요.

<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);
    }
}

적용 대상