共用方式為


DoubleTappedEventHandler 代理人

定義

表示將處理 DoubleTapped 事件的方法。

public delegate void DoubleTappedEventHandler(Platform::Object ^ sender, DoubleTappedRoutedEventArgs ^ e);
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(824496165, 1191, 19781, 130, 94, 130, 4, 166, 36, 219, 244)]
class DoubleTappedEventHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(824496165, 1191, 19781, 130, 94, 130, 4, 166, 36, 219, 244)]
public delegate void DoubleTappedEventHandler(object sender, DoubleTappedRoutedEventArgs e);
Public Delegate Sub DoubleTappedEventHandler(sender As Object, e As DoubleTappedRoutedEventArgs)

參數

sender
Object

Platform::Object

IInspectable

附加事件處理常式的物件。

e
DoubleTappedRoutedEventArgs

事件的事件資料。

屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列程式碼範例顯示 輸入範例中的案例 3。 此程式碼顯示使用HoldingTappedDoubleTapped 和 RightTapped事件進行直接操作的一些使用模式。

<StackPanel>
  <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
    <Button x:Name="scenario3Reset" Content="Reset" Margin="0,0,10,0" 
      Click="Scenario3Reset" />
  </StackPanel>
  <StackPanel Orientation="Horizontal">
    <Border x:Name="bTapped" Background="Red" 
      Height="100" Width="150" CornerRadius="20" Margin="20" 
      BorderBrush="Black" BorderThickness="2">
      <TextBlock Style="{StaticResource BasicTextStyle}" Text="Tap" 
        HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
    <Border x:Name="bDoubleTapped" Background="Red" 
      Height="100" Width="150" CornerRadius="20" Margin="20" 
      BorderBrush="Black" BorderThickness="2">
      <TextBlock Style="{StaticResource BasicTextStyle}" 
        Text="Double Tap" 
        HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
    <Border x:Name="bRightTapped" Background="Red" 
      Height="100" Width="150" CornerRadius="20" Margin="20" 
      BorderBrush="Black" BorderThickness="2">
      <TextBlock Style="{StaticResource BasicTextStyle}" 
        Text="Press, Hold and Lift" TextWrapping="Wrap" 
        HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
    <Border x:Name="bHolding" Background="Red" 
      Height="100" Width="150" CornerRadius="20" Margin="20" 
      BorderBrush="Black" BorderThickness="2">
      <TextBlock Style="{StaticResource BasicTextStyle}" Text="Hold" 
        HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
  </StackPanel>
</StackPanel>
public Scenario3()
{
    this.InitializeComponent();
    bTapped.Tapped += new TappedEventHandler(bTapped_Tapped);
    bDoubleTapped.DoubleTapped += new DoubleTappedEventHandler(
        bDoubleTapped_DoubleTapped);
    bRightTapped.RightTapped += new RightTappedEventHandler(
        bRightTapped_RightTapped);
    bHolding.Holding += new HoldingEventHandler(bHolding_Holding);
}

private void Scenario3UpdateVisuals(Border border, String gesture)
{
    switch (gesture.ToLower())
    {
        case "holding":
            border.Background = new SolidColorBrush(Colors.Yellow);
            break;
        default:
            border.Background = new SolidColorBrush(Colors.Green);
            break;
    }

    ((TextBlock)border.Child).Text = gesture;
}

private void bHolding_Holding(object sender, HoldingRoutedEventArgs e)
{
    string holdingState = 
        (e.HoldingState == Windows.UI.Input.HoldingState.Started) ? 
        "Holding" : "Held";
    Scenario3UpdateVisuals(sender as Border, holdingState);
}

private void bDoubleTapped_DoubleTapped(object sender, 
    DoubleTappedRoutedEventArgs e)
{
    Scenario3UpdateVisuals(sender as Border, "Double Tapped");
}

private void bRightTapped_RightTapped(object sender, 
    RightTappedRoutedEventArgs e)
{
    Scenario3UpdateVisuals(sender as Border, "Right Tapped");
}

private void bTapped_Tapped(object sender, TappedRoutedEventArgs e)
{
    Scenario3UpdateVisuals(sender as Border, "Tapped");
}

private void Scenario3Reset(object sender, RoutedEventArgs e)
{
    Scenario3Reset();
}

private void Scenario3Reset()
{
    bTapped.Background = new SolidColorBrush(Colors.Red);
    bHolding.Background = new SolidColorBrush(Colors.Red);
    bDoubleTapped.Background = new SolidColorBrush(Colors.Red);
    bRightTapped.Background = new SolidColorBrush(Colors.Red);
}
Public Sub New()
    Me.InitializeComponent()
    AddHandler bTapped.Tapped, AddressOf bTapped_Tapped
    AddHandler bDoubleTapped.DoubleTapped, AddressOf bDoubleTapped_DoubleTapped
    AddHandler bRightTapped.RightTapped, AddressOf bRightTapped_RightTapped
    AddHandler bHolding.Holding, AddressOf bHolding_Holding
End Sub

''' <summary>
''' Invoked when this page is about to be displayed in a Frame.
''' </summary>
''' <param name="e">Event data that describes how this page was reached.  The Parameter
''' property is typically used to configure the page.</param>
Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs)
End Sub

Private Sub Scenario3UpdateVisuals(border As Border, gesture As String)
    Select Case gesture.ToLower()
        Case "holding"
            border.Background = New SolidColorBrush(Colors.Yellow)
            Exit Select
        Case Else
            border.Background = New SolidColorBrush(Colors.Green)
            Exit Select
    End Select

    DirectCast(border.Child, TextBlock).Text = gesture
End Sub

Private Sub bHolding_Holding(sender As Object, e As HoldingRoutedEventArgs)
    Dim holdingState As String = If((e.HoldingState = Windows.UI.Input.HoldingState.Started), "Holding", "Held")
    Scenario3UpdateVisuals(TryCast(sender, Border), holdingState)
End Sub

Private Sub bDoubleTapped_DoubleTapped(sender As Object, e As DoubleTappedRoutedEventArgs)
    Scenario3UpdateVisuals(TryCast(sender, Border), "Double Tapped")
End Sub
Private Sub bRightTapped_RightTapped(sender As Object, e As RightTappedRoutedEventArgs)
    Scenario3UpdateVisuals(TryCast(sender, Border), "Right Tapped")
End Sub
Private Sub bTapped_Tapped(sender As Object, e As TappedRoutedEventArgs)
    Scenario3UpdateVisuals(TryCast(sender, Border), "Tapped")
End Sub

Private Sub Scenario3ResetMethod(sender As Object, e As RoutedEventArgs)
    Reset()
End Sub

Private Sub Reset()
    bTapped.Background = New SolidColorBrush(Colors.Red)
    bHolding.Background = New SolidColorBrush(Colors.Red)
    bDoubleTapped.Background = New SolidColorBrush(Colors.Red)
End Sub

適用於