Bagikan melalui


Window.Activated Kejadian

Definisi

Terjadi ketika jendela berhasil diaktifkan.

// Register
event_token Activated(TypedEventHandler<IInspectable, WindowActivatedEventArgs const&> const& handler) const;

// Revoke with event_token
void Activated(event_token const* cookie) const;

// Revoke with event_revoker
Window::Activated_revoker Activated(auto_revoke_t, TypedEventHandler<IInspectable, WindowActivatedEventArgs const&> const& handler) const;
public event TypedEventHandler<object,WindowActivatedEventArgs> Activated;
function onActivated(eventArgs) { /* Your code */ }
window.addEventListener("activated", onActivated);
window.removeEventListener("activated", onActivated);
- or -
window.onactivated = onActivated;
Public Custom Event Activated As TypedEventHandler(Of Object, WindowActivatedEventArgs) 

Jenis Acara

Contoh

Contoh kode berikut menunjukkan pola penggunaan umum untuk peristiwa ini.

void Current_Activated(object sender, WindowActivatedEventArgs e)
{
    if (e.WindowActivationState == WindowActivationState.Deactivated)
    {
        // Show the "paused" UI. 
        VisualStateManager.GoToState(this, "PauseUI", false);
    }
    else if (e.WindowActivationState == WindowActivationState.PointerActivated 
    || e.WindowActivationState == WindowActivationState.CodeActivated)
    {
        // Show the "active" UI. 
        VisualStateManager.GoToState(this, "ActivateUI", false);
    }
}

Keterangan

Kejadian ini terjadi ketika Jendela telah diaktifkan atau dinonaktifkan oleh sistem. Aplikasi dapat menentukan status Window aktivasi dengan memeriksa properti WindowActivationState . Window dapat terlihat di layar tetapi tidak aktif (misalnya, di aplikasi yang di-snap). Selain itu, jika ada bagian lain dari sistem yang mengambil fokus jauh dari jendela, peristiwa ini akan terjadi. Ini bisa terjadi sebagai akibat dari interaksi atau kode pengguna, dan WindowActivationState akan menunjukkan tindakan mana yang telah terjadi.

Berlaku untuk

Lihat juga