TappedRoutedEventArgs Class

Definition

Provides event data for the Tapped event.

public ref class TappedRoutedEventArgs sealed : RoutedEventArgs
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class TappedRoutedEventArgs final : RoutedEventArgs
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class TappedRoutedEventArgs : RoutedEventArgs
Public NotInheritable Class TappedRoutedEventArgs
Inherits RoutedEventArgs
Inheritance
Object Platform::Object IInspectable RoutedEventArgs TappedRoutedEventArgs
Attributes

Examples

The following snippets are from Scenario 1 - Input events of the Basic input sample.

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_Tapped(Windows::Foundation::IInspectable const&, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& args)
{
    tapTarget.Background(Windows::UI::Xaml::Media::SolidColorBrush(Windows::UI::Colors::DeepSkyBlue()));
    tapTargetText.Text(L"Tapped");
}
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_Tapped(Object^ sender, TappedRoutedEventArgs^ e)
{
    tapTarget->Background = ref new SolidColorBrush(Windows::UI::Colors::DeepSkyBlue);
    tapTargetText->Text = "Tapped";
}
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_Tapped(object sender, TappedRoutedEventArgs e)
{
    tapTarget.Background = new SolidColorBrush(Windows.UI.Colors.DeepSkyBlue);
    tapTargetText.Text = "Tapped";
}

Remarks

A Tapped event is sent whenever a mouse is clicked or a finger or pen taps the object

Constructors

TappedRoutedEventArgs()

Initializes a new instance of the TappedRoutedEventArgs class.

Properties

Handled

Gets or sets a value that marks the routed event as handled. A true value for Handled prevents most handlers along the event route from handling the same event again.

OriginalSource

Gets a reference to the object that raised the event. This is often a template part of a control rather than an element that was declared in your app UI.

(Inherited from RoutedEventArgs)
PointerDeviceType

Gets the PointerDeviceType for the pointer device that initiated the associated input event.

Methods

GetPosition(UIElement)

Returns the x- and y-coordinates of the pointer position, optionally evaluated against a coordinate origin of a supplied UIElement.

Applies to

See also