1

I have a cs file for Drag drop Element. In the Method after the drop is completed (OnManipulationCompleted) I would like to initiate/trigger the 3 button clicks from another WPF page which has 3 buttons within the OnManipulationCompleted method.

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**
        }

The Other Wpf page which has these buttons having function for three buttons .After each button drop it would navigate to another page.

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;
    }


}

How will I do that ?Please help

1 Answers1

1

You need to have an instance of the page you want to trigger events on. If that page exists then you can get that instance based on your application architecture otherwise there is no way to call non-static members without instantiating an object.

Once you get that page instance call the respective event handlers as methods. As an example if that instance is named targetPage then

   targetPage.Tip_Click(null, new EventArgs());
Hassaan Akbar
  • 195
  • 3
  • 12
  • Thank you. I am able to call the Tip_Click. But it does not trigger the click automatically after the drop is completed. We have to still click on the button. I put a break point on the targetPage.Tip_Click(null, new EventArgs()); to check if it enters the Tip_CLick. It enters but does not perform functions PerformCLick() Does not work for me. How to make the click work automatically. – Payal Kumar Aug 22 '16 at 14:58
  • Sorryy PerformClick was in button class of another namespace. it wont work for u..i will edit the answer.. but execution of the event handler without actual button click wont suffice your need? What does it miss? – Hassaan Akbar Aug 22 '16 at 17:23
  • Ok.. i tried this.. hopefully it will suffice ur need `button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));` call this method on all three buttons after the drop is completed. – Hassaan Akbar Aug 22 '16 at 18:34