RightTappedEventHandler 委托
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示将处理 RightTapped 路由事件的方法。
public delegate void RightTappedEventHandler(Platform::Object ^ sender, RightTappedRoutedEventArgs ^ e);
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.Guid(1349575471, 15815, 22223, 143, 221, 222, 27, 64, 208, 180, 114)]
public delegate void RightTappedEventHandler(object sender, RightTappedRoutedEventArgs e);
Public Delegate Sub RightTappedEventHandler(sender As Object, e As RightTappedRoutedEventArgs)
参数
- sender
-
Object
Platform::Object
附加处理程序的对象。
事件的事件数据。
- 属性
示例
下面的代码示例演示 输入示例中的方案 3。 此代码显示了使用 Holding、Tappped、DoubleTapped 和 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);
}