Share via


StatusChangedEventArgs 클래스

정의

StatusChanged 이벤트에 대한 정보를 제공합니다.

public ref class StatusChangedEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class StatusChangedEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class StatusChangedEventArgs
Public NotInheritable Class StatusChangedEventArgs
상속
Object Platform::Object IInspectable StatusChangedEventArgs
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)
앱 기능
location ID_CAP_LOCATION [Windows Phone]

예제

이 코드 예제에서는 StatusChanged 이벤트가 처리되는 방법을 보여 줍니다. Geolocator 개체는 StatusChanged 이벤트를 트리거하여 사용자의 위치 설정이 변경되었음을 나타냅니다. 해당 이벤트는 인수의 Status 속성(유형 PositionStatus)을 통해 해당 상태를 전달합니다. 이 메서드는 UI 스레드로부터 호출되지 않고 Dispatcher 개체가 UI 변경 사항을 호출합니다. 자세한 내용은 현재 위치 가져오기를 참조하세요.

using Windows.UI.Core;
...
async private void OnStatusChanged(Geolocator sender, StatusChangedEventArgs e)
{
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        // Show the location setting message only if status is disabled.
        LocationDisabledMessage.Visibility = Visibility.Collapsed;

        switch (e.Status)
        {
            case PositionStatus.Ready:
                // Location platform is providing valid data.

                // notify user: Location platform is ready
                break;

            case PositionStatus.Initializing:
                // Location platform is attempting to acquire a fix. 

                // notify user: Location platform is attempting to obtain a position
                break;

            case PositionStatus.NoData:
                // Location platform could not obtain location data.

                // notify user: Not able to determine the location
                break;

            case PositionStatus.Disabled:
                // The permission to access location data is denied by the user or other policies.

                // notify user: Access to location is denied

                // Clear cached location data if any
                break;

            case PositionStatus.NotInitialized:
                // The location platform is not initialized. This indicates that the application 
                // has not made a request for location data.

                // notify user: No request for location is made yet
                break;

            case PositionStatus.NotAvailable:
                // The location platform is not available on this version of the OS.

                // notify user: Location is not available on this version of the OS
                break;

            default:
                // unknown case
                break;
        }
    });
}

설명

이 개체는 StatusChanged 이벤트에 대한 처리기에 전달된 인수입니다.

속성

Status

Geolocator 개체의 업데이트된 상태.

적용 대상

추가 정보