Partilhar via


HoldingRoutedEventArgs Classe

Definição

Fornece dados de evento para o evento Holding .

public ref class HoldingRoutedEventArgs sealed : RoutedEventArgs
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HoldingRoutedEventArgs final : RoutedEventArgs
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class HoldingRoutedEventArgs final : RoutedEventArgs
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HoldingRoutedEventArgs : RoutedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HoldingRoutedEventArgs : RoutedEventArgs
Public NotInheritable Class HoldingRoutedEventArgs
Inherits RoutedEventArgs
Herança
Object Platform::Object IInspectable RoutedEventArgs HoldingRoutedEventArgs
Atributos

Requisitos do Windows

Família de dispositivos
Windows 10 (introduzida na 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduzida na v1.0)

Exemplos

Os snippets a seguir são do Cenário 1 – Eventos de entrada do exemplo de entrada Básico.

Scenario1::Scenario1()
{
    InitializeComponent();

    // pointer press/release handlers
    pressedTarget.PointerPressed(this, &Scenario1::target_PointerPressed);
    pressedTarget.PointerReleased(this, &Scenario1::target_PointerReleased);

    // pointer enter/exit handlers
    enterExitTarget.PointerEntered(this, &Scenario1::target_PointerEntered);
    enterExitTarget.PointerExited(this, &Scenario1::target_PointerExited);

    // gesture handlers
    tapTarget.Tapped(this, &Scenario1::target_Tapped);
    tapTarget.DoubleTapped(this, &Scenario1::target_DoubleTapped);

    holdTarget.Holding(this, &Scenario1::target_Holding);
    holdTarget.RightTapped(this, &Scenario1::target_RightTapped);
}

void Scenario1::target_Holding(Windows::Foundation::IInspectable const&, Windows::UI::Xaml::Input::HoldingRoutedEventArgs const& args)
{
    if (args.HoldingState() == Windows::UI::Input::HoldingState::Started)
    {
        holdTarget.Background(Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::DeepSkyBlue()));
        holdTargetText.Text(L"Holding");
    }
    else if (args.HoldingState() == Windows::UI::Input::HoldingState::Completed)
    {
        holdTarget.Background(Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::LightGray()));
        holdTargetText.Text(L"Held");
    }
    else
    {
        holdTarget.Background(Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::LightGray()));
        holdTargetText.Text(L"Hold Canceled");
    }
}
Scenario1::Scenario1()
{
    InitializeComponent();

    // pointer press/release handlers
    pressedTarget->PointerPressed += ref new PointerEventHandler(this, &Scenario1::target_PointerPressed);
    pressedTarget->PointerReleased += ref new PointerEventHandler(this, &Scenario1::target_PointerReleased);

    // pointer enter/exit handlers
    enterExitTarget->PointerEntered += ref new PointerEventHandler(this, &Scenario1::target_PointerEntered);
    enterExitTarget->PointerExited += ref new PointerEventHandler(this, &Scenario1::target_PointerExited);

    // gesture handlers
    tapTarget->Tapped += ref new TappedEventHandler(this, &Scenario1::target_Tapped);
    tapTarget->DoubleTapped += ref new DoubleTappedEventHandler(this, &Scenario1::target_DoubleTapped);

    holdTarget->Holding += ref new HoldingEventHandler(this, &Scenario1::target_Holding);
    holdTarget->RightTapped += ref new RightTappedEventHandler(this, &Scenario1::target_RightTapped);
}

void Scenario1::target_Holding(Object^ sender, HoldingRoutedEventArgs^ e)
{
    if (e->HoldingState == Windows::UI::Input::HoldingState::Started)
    {
        holdTarget->Background = ref new SolidColorBrush(Windows::UI::Colors::DeepSkyBlue);
        holdTargetText->Text = "Holding";
    }
    else if (e->HoldingState == Windows::UI::Input::HoldingState::Completed)
    {
        holdTarget->Background = ref new SolidColorBrush(Windows::UI::Colors::LightGray);
        holdTargetText->Text = "Held";
    }
    else
    {
        holdTarget->Background = ref new SolidColorBrush(Windows::UI::Colors::LightGray);
        holdTargetText->Text = "Hold Canceled";
    }
}
public Scenario1()
{
    this.InitializeComponent();

    // pointer press/release handlers
    pressedTarget.PointerPressed += new PointerEventHandler(target_PointerPressed);
    pressedTarget.PointerReleased += new PointerEventHandler(target_PointerReleased);

    // pointer enter/exit handlers
    enterExitTarget.PointerEntered += new PointerEventHandler(target_PointerEntered);
    enterExitTarget.PointerExited += new PointerEventHandler(target_PointerExited);

    // gesture handlers
    tapTarget.Tapped += new TappedEventHandler(target_Tapped);
    tapTarget.DoubleTapped += new DoubleTappedEventHandler(target_DoubleTapped);
    holdTarget.Holding += new HoldingEventHandler(target_Holding);
    holdTarget.RightTapped += new RightTappedEventHandler(target_RightTapped);
}

void target_Holding(object sender, HoldingRoutedEventArgs e)
{
    if (e.HoldingState == Windows.UI.Input.HoldingState.Started)
    {
        holdTarget.Background = new SolidColorBrush(Windows.UI.Colors.DeepSkyBlue);
        holdTargetText.Text = "Holding";
    }
    else if (e.HoldingState == Windows.UI.Input.HoldingState.Completed)
    {
        holdTarget.Background = new SolidColorBrush(Windows.UI.Colors.LightGray);
        holdTargetText.Text = "Held";
    }
    else
    {
        holdTarget.Background = new SolidColorBrush(Windows.UI.Colors.LightGray);
        holdTargetText.Text = "Hold Canceled";
    }
}
Public Sub New()
    Me.InitializeComponent()
    AddHandler pressedTarget.PointerPressed, New PointerEventHandler(AddressOf target_PointerPressed)
    AddHandler pressedTarget.PointerReleased, New PointerEventHandler(AddressOf target_PointerReleased)
    AddHandler enterExitTarget.PointerEntered, New PointerEventHandler(AddressOf target_PointerEntered)
    AddHandler enterExitTarget.PointerExited, New PointerEventHandler(AddressOf target_PointerExited)
    AddHandler tapTarget.Tapped, New TappedEventHandler(AddressOf target_Tapped)
    AddHandler tapTarget.DoubleTapped, New DoubleTappedEventHandler(AddressOf target_DoubleTapped)
    AddHandler holdTarget.Holding, New HoldingEventHandler(AddressOf target_Holding)
    AddHandler holdTarget.RightTapped, New RightTappedEventHandler(AddressOf target_RightTapped)
End Sub

Sub target_Holding(sender As Object, e As HoldingRoutedEventArgs)
    If e.HoldingState = Windows.UI.Input.HoldingState.Started Then
        holdTarget.Background = New SolidColorBrush(Windows.UI.Colors.DeepSkyBlue)
        holdTargetText.Text = "Holding"
    ElseIf e.HoldingState = Windows.UI.Input.HoldingState.Completed Then
        holdTarget.Background = New SolidColorBrush(Windows.UI.Colors.LightGray)
        holdTargetText.Text = "Held"
    Else
        holdTarget.Background = New SolidColorBrush(Windows.UI.Colors.LightGray)
        holdTargetText.Text = "Hold Canceled"
    End If
End Sub

Comentários

Um evento Holding é enviado sempre que um dedo, uma caneta ou um dispositivo de apontamento semelhante é pressionado e mantido em um objeto .

Depois que um limite de tempo curto tiver decorrido, o evento será enviado com um HoldingState do tipo Iniciado.

Quando o dispositivo é levantado (após um evento Holding ), outro evento Holding é enviado com um HoldingState do tipo Concluído.

Se o usuário cancelar a retenção depois de ser iniciada, mas antes de ser concluída, um evento Holding será enviado com um HoldingState do tipo Cancelado.

Construtores

HoldingRoutedEventArgs()

Inicializa uma nova instância da classe HoldingRoutedEventArgs .

Propriedades

Handled

Obtém ou define um valor que marca o evento roteado como manipulado. Um valor verdadeiro para Handled impede que a maioria dos manipuladores ao longo da rota de evento manipule o mesmo evento novamente.

HoldingState

Obtém o HoldingState subjacente para a interação

OriginalSource

Obtém uma referência ao objeto que gerou o evento. Isso geralmente é uma parte de modelo de um controle em vez de um elemento que foi declarado na interface do usuário do aplicativo.

(Herdado de RoutedEventArgs)
PointerDeviceType

Obtém o PointerDeviceType para o dispositivo de ponteiro que iniciou o evento de entrada associado.

Métodos

GetPosition(UIElement)

Retorna as coordenadas x e y da posição do ponteiro, opcionalmente avaliadas em relação a uma origem de coordenada de um UIElement fornecido.

Aplica-se a

Confira também