UIElement.CaptureStylus 方法


尝试将触笔强制捕获到此元素。Attempts to force capture of the stylus to this element.

 virtual bool CaptureStylus();
public bool CaptureStylus ();
abstract member CaptureStylus : unit -> bool
override this.CaptureStylus : unit -> bool
Public Function CaptureStylus () As Boolean



如果成功捕获了触笔,则为 true;否则为 falsetrue if the stylus was successfully captured; otherwise, false.



基于基础默认触笔设备的默认实现始终返回 trueThe default implementation based on the underlying default stylus device always returns true. 但是,如果你要扩展为输入系统提供设备实现的输入设备,则可以使用可能返回不同结果的备用触笔设备实现创建系统。However, if you are extending the input devices that provide the device implementation for the input system, it is possible to create a system with an alternative stylus device implementation that might return different results.

当某个元素捕获触笔时,它将接收触笔输入,即使触笔位于其边界之外。When an element captures the stylus, it receives stylus input even if the stylus is outside its bounds. 通常仅在拖放操作期间捕获触笔。The stylus is typically captured only during drag-and-drop operations.

调用此方法将调用基础静态 Stylus 方法 CaptureCalling this method calls an underlying static Stylus method Capture. 实际捕获行为是由活动的触笔设备实现实现的。The actual capture behavior is implemented by the active stylus device implementation.

若要捕获,必须启用一个元素。To be captured, an element must be enabled. 检查是否 IsEnabledtrue 调用之前返回 CaptureStylusCheck whether IsEnabled is true return before you call CaptureStylus.

如果调用 CaptureStylus 返回 trueIsStylusCaptured 则也是 trueIf calling CaptureStylus returns true, IsStylusCaptured is also true.