我可能是錯在我看來 - 但至少之前我看了一段時間相當長的一段長度爲InputManager
。
我的簡歷是:冒泡和隧道是由InputManager
完成的。然而,致電uielement.Raise()
將只能直接發送活動(不管RoutingStrategy
爲Ray Burns mentioed)。
但根據RoutingStrategy
的InputManager
(猜測)上升和下降CompositionRoot
之間的視覺樹和VisualTreeHlper.Hittest()-
編視覺並提供隧道和bublling事件。
有一種方法通過輸入管理,以提高活動,但它不是官方的,需要反思(我把它從另一個崗位#1):
void RaiseMouseInputReportEvent(Visual eventSource, int timestamp, int pointX, int pointY, int wheel)
{
Assembly targetAssembly = Assembly.GetAssembly(typeof(InputEventArgs));
Type mouseInputReportType = targetAssembly.GetType("System.Windows.Input.RawMouseInputReport");
Object mouseInputReport = mouseInputReportType.GetConstructors()[0].Invoke(new Object[] {
InputMode.Foreground, timestamp, PresentationSource.FromVisual(eventSource),
RawMouseActions.AbsoluteMove | RawMouseActions.Activate,
pointX, pointY, wheel, IntPtr.Zero });
mouseInputReportType.GetField("_isSynchronize", BindingFlags.NonPublic | BindingFlags.Instance)
.SetValue(mouseInputReport, true);
InputEventArgs inputReportEventArgs = (InputEventArgs)targetAssembly
.GetType("System.Windows.Input.InputReportEventArgs")
.GetConstructors()[0]
.Invoke(new Object[] {
Mouse.PrimaryDevice,
mouseInputReport });
inputReportEventArgs.RoutedEvent = (RoutedEvent)typeof(InputManager)
.GetField("PreviewInputReportEvent", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
.GetValue(null);
bool handled = InputManager.Current.ProcessInput((InputEventArgs)inputReportEventArgs);
}