Share via


InputActivationListener Klasse

Definition

Bietet die Möglichkeit, auf den Aktivierungsstatus eines Objekts zuzugreifen und Änderungen daran zu beobachten.

public ref class InputActivationListener sealed : InputObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65537)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InputActivationListener final : InputObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65537)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InputActivationListener : InputObject
Public NotInheritable Class InputActivationListener
Inherits InputObject
Vererbung
Object Platform::Object IInspectable InputObject InputActivationListener
Attribute

Beispiele

Das folgende Windows App SDK Beispiel zeigt, wie sie auf Aktivierungsereignisse für ein Microsoft.UI.Windowing.AppWindow Objekt reagieren:

class RespondToAppWindowActivation
{
    InputActivationListener inputActivationListener;

    public RespondToAppWindowActivation(Microsoft.UI.Windowing.AppWindow appWindow)
    {
        inputActivationListener = InputActivationListener.GetForWindowId(appWindow.Id);

        inputActivationListener.InputActivationChanged += OnActivationChanged;
    }

    void OnActivationChanged(
        InputActivationListener sender,
        InputActivationListenerActivationChangedEventArgs args)
    {
        if (sender.State == InputActivationState.Activated)
        {
            System.Diagnostics.Debug.WriteLine("AppWindow was activated.");

            LeaveMyBackgroundMode();
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("AppWindow was deactivated.");

            EnterMyBackgroundMode();
        }
    }
}

Hinweise

Wenn das einem InputActivationListener zugeordnete Objekt zerstört wird, wird das InputActivationListener-Objekt implizit verworfen. Weitere Informationen finden Sie unter InputObject .

Eigenschaften

DispatcherQueue

Ruft die DispatcherQueue für das InputObject ab.

(Geerbt von InputObject)
State

Ruft den Aktivierungsstatus des -Objekts ab.

Methoden

GetForIsland(ContentIsland)

Ruft ein InputActivationListener -Objekt für das angegebene ContentIsland ab.

GetForWindowId(WindowId)

Ruft ein InputActivationListener -Objekt für das angegebene Fenster der obersten Ebene ab.

Ereignisse

InputActivationChanged

Tritt auf, wenn sich der Eingabeaktivierungsstatus des zugeordneten Objekts ändert.

Gilt für:

Weitere Informationen