未调用 ScatterViewItem 操作事件处理程序
ScatterViewItem manipulation event handlers not being called
我正在开发一个基于 WPF Surface 触摸屏的应用程序,它使用 ScatterViewItem
控件。
使用触摸输入时,所有操作都运行良好:旋转、缩放、平移。
不幸的是,当我尝试在操作发生时执行一些代码时,例如 C# 代码隐藏中的以下代码,没有任何反应。
ManipulationDelta += myItemManipulationDelta;
private void myItemManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
Application.Current.Shutdown(); //just to see if it's even happening
}
我尝试将类似的处理程序添加到 ManipulationStarting
和 ManipulationStarted
但没有成功。
更新:
正如答案所建议的那样,我尝试了以下操作,但没有成功:
public partial class MyControl: ScatterViewItem
{
//constructor for custom control
private void MainWindow_ManipulationDelta2(object sender, ManipulationDeltaEventArgs e)
{
Application.Current.Shutdown();
}
private void MainWindow_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
// normal handling of the event.
}
public MyControl()
{
ManipulationDelta += MainWindow_ManipulationDelta2;
ManipulationDelta += MainWindow_ManipulationDelta;
// more stuff ...
}
}
事实证明,我必须在基于 ScatterViewItem
的自定义控件中实际注册一个 ContainerManipulationDelta
事件,以便事件正确触发。现在一切正常。
我正在开发一个基于 WPF Surface 触摸屏的应用程序,它使用 ScatterViewItem
控件。
使用触摸输入时,所有操作都运行良好:旋转、缩放、平移。
不幸的是,当我尝试在操作发生时执行一些代码时,例如 C# 代码隐藏中的以下代码,没有任何反应。
ManipulationDelta += myItemManipulationDelta;
private void myItemManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
Application.Current.Shutdown(); //just to see if it's even happening
}
我尝试将类似的处理程序添加到 ManipulationStarting
和 ManipulationStarted
但没有成功。
更新: 正如答案所建议的那样,我尝试了以下操作,但没有成功:
public partial class MyControl: ScatterViewItem
{
//constructor for custom control
private void MainWindow_ManipulationDelta2(object sender, ManipulationDeltaEventArgs e)
{
Application.Current.Shutdown();
}
private void MainWindow_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
// normal handling of the event.
}
public MyControl()
{
ManipulationDelta += MainWindow_ManipulationDelta2;
ManipulationDelta += MainWindow_ManipulationDelta;
// more stuff ...
}
}
事实证明,我必须在基于 ScatterViewItem
的自定义控件中实际注册一个 ContainerManipulationDelta
事件,以便事件正确触发。现在一切正常。