Bagikan melalui


StatusChangedEventArgs Kelas

Definisi

Menyediakan informasi untuk peristiwa 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
Warisan
Object Platform::Object IInspectable StatusChangedEventArgs
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
Kemampuan aplikasi
location ID_CAP_LOCATION [Windows Phone]

Contoh

Contoh kode ini menunjukkan bagaimana peristiwa StatusChanged ditangani . Objek Geolokator memicu peristiwa StatusChanged untuk menunjukkan bahwa pengaturan lokasi pengguna berubah. Kejadian tersebut melewati status yang sesuai melalui properti Status argumen (dari jenis PositionStatus). Perhatikan bahwa metode ini tidak dipanggil dari utas UI dan objek Dispatcher memanggil perubahan UI. Untuk informasi selengkapnya, lihat Mendapatkan lokasi saat ini.

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

Keterangan

Objek ini adalah argumen yang diteruskan ke handler untuk peristiwa StatusChanged .

Properti

Status

Status objek Geolocator yang diperbarui.

Berlaku untuk

Lihat juga