HoldingRoutedEventArgs 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public ref class HoldingRoutedEventArgs 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 HoldingRoutedEventArgs 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 HoldingRoutedEventArgs : RoutedEventArgs
Public NotInheritable Class HoldingRoutedEventArgs
Inherits RoutedEventArgs
- 继承
- 属性
示例
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";
}
}
注解
每当在对象上按下并按住手指、笔或类似的指针设备时,将发送 Holding 事件。
经过短时间阈值后,事件将发送 Started 类型的 HoldingState。
当设备在保持事件) 后 (提升时,另一个 Holding 事件将发送类型为 Completed 的 HoldingState。
如果用户在启动后、完成之前取消了保留,则会发送 Hold 事件,并发送类型为 Canceled 的 HoldingState。
构造函数
HoldingRoutedEventArgs() |
初始化 HoldingRoutedEventArgs 类的新实例。 |
属性
Handled |
获取或设置一个值,该值将路由事件标记为已处理。
|
HoldingState |
获取交互的基础 HoldingState 。 |
OriginalSource |
获取对引发事件的 对象的引用。 这通常是控件的模板部分,而不是在应用 UI 中声明的元素。 (继承自 RoutedEventArgs) |
PointerDeviceType |
获取启动关联输入事件的指针设备的 PointerDeviceType 。 |
方法
GetPosition(UIElement) |
返回指针位置的 x 坐标和 y 坐标,可以选择根据提供的 UIElement 的坐标原点计算。 |