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
- 繼承
- 屬性
範例
下列程式碼片段來自 案例 1 -基本輸入範例的輸入事件。
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";
}
}
備註
每當手指、手寫筆或類似的指向裝置按下並保留在物件上時,就會傳送 保留 事件。
一旦經過短時間臨界值,事件就會以Started類型的HoldingState傳送。
當裝置在保留事件) 之後 (,則會以Completed類型的HoldingState傳送另一個Holding事件。
如果使用者在啟動保留之後取消保留,但在完成之前,會以Canceled類型的HoldState傳送Hold事件。
建構函式
HoldingRoutedEventArgs() |
初始化 HoldingRoutedEventArgs 類別的新實例。 |
屬性
Handled |
取得或設定值,這個值會將路由事件標示為已處理。
|
HoldingState |
取得互動的基礎 HoldingState 。 |
OriginalSource |
取得引發事件之 物件的參考。 這通常是控制項的範本部分,而不是在應用程式 UI 中宣告的專案。 (繼承來源 RoutedEventArgs) |
PointerDeviceType |
取得起始相關聯輸入事件的指標裝置的 PointerDeviceType 。 |
方法
GetPosition(UIElement) |
會傳回指標位置的 x 和 Y 座標,選擇性地根據所提供 UIElement的座標原點進行評估。 |