我有一个用于拖放元素的cs文件。在完成删除后的方法中(OnManipulationCompleted)我想从另一个WPF页面启动/触发3次按钮点击,该页面在OnManipulationCompleted方法中有3个按钮。
namespace KinectDemos
{
public class DragDropElementController : IKinectManipulatableController
{
private ManipulatableModel _inputModel;
private KinectRegion _kinectRegion;
private DragDropElement _dragDropElement;
private bool _disposedValue;
public DragDropElementController(IInputModel inputModel, KinectRegion kinectRegion)
{
_inputModel = inputModel as ManipulatableModel;
_kinectRegion = kinectRegion;
_dragDropElement = _inputModel.Element as DragDropElement;
_inputModel.ManipulationStarted += OnManipulationStarted;
_inputModel.ManipulationUpdated += OnManipulationUpdated;
_inputModel.ManipulationCompleted += OnManipulationCompleted;
}
private void OnManipulationCompleted(object sender,
KinectManipulationCompletedEventArgs kinectManipulationCompletedEventArgs)
{**HERE I WOULD LIKE TO INITIATE THE BUTTON CLICKS**
}
其他Wpf页面,其中这些按钮具有三个按钮的功能。每次按下按钮后,它将导航到另一个页面。
Public partial class Beauty : Usercontrol
{
Public void Tip_Click (object sender, RoutedEventArgs e)
{
Afterdrop page1 = new Afterdrop
this.content = page1;
}
Public void Tricks_Click (object sender, RoutedEventArgs e)
{
Afterdrop2 page2 = new Afterdrop2
this.content = page2;
}
Public void Invent_Click (object sender, RoutedEventArgs e)
{
Afterdrop3 page3 = new Afterdrop3
this.content = page3;
}
}
我将如何做到这一点?请帮助
答案 0 :(得分:1)
您需要拥有要触发事件的页面实例。如果该页面存在,那么您可以根据应用程序体系结构获取该实例,否则无法在不实例化对象的情况下调用非静态成员。
获得该页面实例后,将相应的事件处理程序作为方法调用。例如,如果该实例名为targetPage
,那么
targetPage.Tip_Click(null, new EventArgs());